[JS] 객체 Object (key, value, method)

[JS] 객체 Object (key, value, method)

Object(객체)는 boolen, number,strin, undefined를 제외한 나머지라 할 수 있다

< Object 기본 구조 >

const ObjectName = {

key : value,

}

const superman = { name: 'yeji' age: 25, }

객체 안에 함수가 들어 갈 수 있고 이 함수를 method 라 칭한다

const ObjectName = {

key : value,

method: function(){

}

}

* ObjectName.method( ); 로 불러낼 수 있다.

* method 안에서 this를 이용할 수 있다

const superman = { name: 'yeji' age: 25, sayHello: function(){ console.log(`Hi, this is ${this.name}`); } }

!! 화살표 함수는 this 를 갖지 않는다.

2021.09.28 - [Front_end/JS (Javascript)] - [JS] Function 함수 (함수 선언문, 표현식, 화살표 함수)

from http://joyful-ugentstudent-note.tistory.com/32 by ccl(A) rewrite - 2021-10-01 04:01:44