const Person = {
name : 'Kim',
age : 33,
walk : function() {
console.log("걷고 있습니다.");
}
//walk(){
// console.log("걷고 있습니다.");
//} 이렇게 함수를 쓸 수 있다.
}
객체 자기자신을 지칭, Arrow function을 사용하면 this는 브라우저에서는 window, Node js에서는 global을 지칭한다.
const Person = {
name : 'Kim',
age : 33,
walk : function() {
console.log(`${this.name},걷고 있습니다.`);
}
}
여기서의 this.name은 Person이란 객체의 name프로퍼티이다.