📦

Has Property

Has Property
쉬움 객체 +10pts

Problem

Write a function that checks if an object has a specific property.

Examples

Input: hasProperty({a: 1}, "a")
Output: true
Input: hasProperty({a: 1}, "b")
Output: false

Explanation

이 문제는 **in 연산자**를 사용하여 객체에 속성이 존재하는지 확인하는 방법을 학습합니다. ## 핵심 개념: 속성 존재 확인 객체에 특정 속성이 있는지 확인하는 방법은 여러 가지가 있습니다. ### 방법 1: in 연산자 ```javascript key in obj ``` - 상속된 속성도 확인 - 가장 간단한 문법 ### 방법 2: hasOwnProperty ```javascript obj.hasOwnProperty(key) ``` - 자체 속성만 확인 (상속 제외) ### 방법 3: undefined 비교 (권장하지...

View detailed explanation →

Key Concepts

in 연산자 hasOwnProperty 속성 확인 상속 속성
Time: O(1) Space: O(1)
solution.js
Ctrl + Enter
Run tests to see results here.