πŸ“Œkey

문자, 숫자, λ¬Έμžμ—΄, 심볼

데이터 μ ‘κ·Όν•  λ•Œ ν™œμš©ν•  수 μžˆλ‹€.

πŸ“Œvalue

μ›μ‹œκ°’, 객체

✏

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'
}