Object

Object : 객체

  • one of the JavaScript's data types : 자바스크립트의 데이터 타입 중의 하나

  • a collection of related data and/or functionality : 데이터와 함수와 연관된 집합

  • Nearly all objects in JavaScript are instances of Object : 자바스크립트에서 거의 모든 객체는 객체의 인스턴스

  • object = { key : value } : 오브젝트는 key(변수)와 value의(값) 집합체

1. 리터럴 객체와 프로퍼티 : Literals and properties

/*const name = 'ellie';
const age = 4;
print(name, age);
function print(name, age) {
  console.log(name);
  console.log(age);
}
const ellie = { name: 'ellie', age: 4 }; 오브젝트로 관리*/

const obj1 = {}; // {} = 'object literal' syntax
const obj2 = new Object(); // new = 'object constructor' syntax

function print(person) {
  console.log(person.name);
  console.log(person.age);
}

const ellie = { name: 'ellie', age: 4 };
print(ellie);

// with JavaScript magic (dynamically typed language)
// can add properties later
ellie.hasJob = true;
console.log(ellie.hasJob);

// can delete properties later
delete ellie.hasJob;
console.log(ellie.hasJob);

2. 계산된 프로퍼티 : Computed properties

3. Property value shorthand : key와 value의 값이 같을 때 생략 가능한 기능

4. 생성자 함수 : Constructor Function

5. In 연산자 : In operator

property existence check (key in obj) : 해당하는 object 안에 key가 있는지 없는지 확인하는 것

6. for..in vs for..of

7. Fun cloning

Last updated

Was this helpful?