접근 방법
objectName.propertyName
pbjectName["propertyName"]
객체 안에 있는 this 키워드
const person = {
firstName : "John",
lastName : "Doe",
id : 5566,
fullName : function() {
return this.firstName + " " + this.lastName;
}
};
함수에서 쓰인 this 는 person 객체를 가르킨다.
객체 안에 있는 this는 객체를 가르킨다.
The this Keyword
In a function definition, this refers to the "owner" of the function.
In the example above, this is the person object that "owns" the fullName function.
In other words, this.firstName means the firstName property of this object.
메소드 접근방법
objectName.methodName()
'Development (국비 복습 ) > JavaScript' 카테고리의 다른 글
String을 객체로 사용하는 경우 (1) | 2022.09.21 |
---|---|
js \ 백래쉬 사용법 (0) | 2022.09.20 |
자바스크립트 함수 (0) | 2022.09.20 |
자바스크립트 데이터 타입 (1) | 2022.09.20 |
자바스크립트 연산자 (0) | 2022.09.14 |
댓글