var name = "백두산";
var elevation = 2744; // 높이(단위: 미터)
var funHike = { name, elevation };
console.log(funHike) // {name: "백두산", elavation: 2744}
{name: '백두산', elevation: 2744}
elevation: 2744
name: "백두산"
[[Prototype]]: Object
constructor: ƒ Object()
hasOwnProperty: ƒ hasOwnProperty()
isPrototypeOf: ƒ isPrototypeOf()
propertyIsEnumerable: ƒ propertyIsEnumerable()
toLocaleString: ƒ toLocaleString()
toString: ƒ toString()
valueOf: ƒ valueOf()
defineGetter: ƒ defineGetter()
defineSetter: ƒ defineSetter()
lookupGetter: ƒ lookupGetter()
lookupSetter: ƒ lookupSetter()
proto: (...)
get proto: ƒ proto()
set proto: ƒ proto()
var name = "백두산";
var elevation = 2744;
var print = function () {
console.log(`${this.name}의 높이는 ${this.elevation}m 입니다.`);
}
var funHike = { name, elevation, print }
funHike.print() // 백두산의 높이는 2744m 입니다.
백두산의 높이는 2744m 입니다.
function myFun() {
return this; // window
}
console.log(myFun());
var num = 0;
function addNum() {
this.num = 100;
num++;
console.log(num); // 101
console.log(window.num); // 101
console.log(num === window.num); // true
}
addNum();