Skip to content

Commit

Permalink
#2.6.Objects
Browse files Browse the repository at this point in the history
  • Loading branch information
KwanHoo committed Jan 21, 2023
1 parent e7191a8 commit 8ea6aaa
Showing 1 changed file with 49 additions and 1 deletion.
50 changes: 49 additions & 1 deletion script.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,52 @@ daysOfWeekText.push('testDay');
console.log(daysOfWeekText);

const toBuy = ["chair", "desk"];
toBuy.push("monitor");
toBuy.push("monitor");

//* Objects

// 1) variable
const playerName = "Ralo";
const playerPoints = 2400;
const playerHandsome = false;
const playerFat = "little bit";
//player.name ??
//player.point??
//player.handsome


// 2) array
//player[0] == name;
//player[1] == points;
const player1 = ["Paka", "9999", false, "MolRu" ];

// 3) object
const player3 = {
name: "Dopa", //property
points: "2800",
playerHandsome: true,
playerFat: "not bad"
};

console.log(player3);
console.log(player3.name);
console.log(player3["points"]);
// palyer.name

// object property add or update
//! 의문점!!! const(상수)는 수정을 할 수 없다고 했는디???
//! player3를 상수로 선언했는데 왜 프로퍼티 추가가되지???
//* object 안의 무언가를 수정하는 거임, 객체는 아직 동일함
//-> 에러는 상수 전체를 하나의 값으로서 업데이트 하려고 할 떄 발생하게 됨

player3.fat = false; //add
player3.points = 3000;
console.log(player3);



//-> 에러는 상수 전체를 하나의 값으로서 업데이트 하려고 할 떄 발생하게 됨
//* 에러 예시
//* player3 = false;
//* console.log(player3); -> error 메세지 출력됨

0 comments on commit 8ea6aaa

Please sign in to comment.