λ¬Έμ, μ«μ, λ¬Έμμ΄, μ¬λ³Ό
λ°μ΄ν° μ κ·Όν λ νμ©ν μ μλ€.
μμκ°, κ°μ²΄
β
let apple = {
name: "apple",
"hello-morning": "good morning",
0: 1,
["hello"]: "hello",
}
βλ§μΉ¨ν νκΈ°λ²(dot notation)
console.log(apple.name);
console.log(apple.hello);
βλκ΄νΈ νκΈ°λ²(bracket notation)
console.log(apple["name"]);
console.log(apple[0]);
console.log(apple["hello"]);
console.log(apple["hello-morning"]);
πμμ±μ μΆκ°
apple.color = "red";
console.log(apple.color); //red
console.log(apple["color"]); //red
console.log(apple);
//{
'0': 1,
name: 'apple',
'hello-morning': 'good morning',
hello: 'Hello',
color: 'red' //->μΆκ°λ¨
}
πμμ±μ μμ β delete ν€μλ νμ©
delete apple.color;
console.log(apple.color); //undefined
console.log(apple);
//{
'0': 1,
name: 'apple',
'hello-morning': 'good morning',
hello: 'Hello'
}