본문 바로가기
JavsScript

객체 (4줄 짜리)

by applejune 2022. 2. 11.

//객체

const superman ={
name : 'clark',
age : 30 ,
}

superman.hairColor = 'greenyellow';
superman['hobby'] ='baseball';
console.log(superman)



***************************************************************************
***************************************************************************
함수 속 객체

function makeObject(name, age){
return {
name,
age,
hobby:"baseball"
};
}

const Mini = makeObject("Mikimousei", 20 );
console.log(Mini);

//추가로 불린 값 물어볼 때
console.log("name" in Mini);

'JavsScript' 카테고리의 다른 글

객체 for ... in  (0) 2022.02.11
객체 2  (0) 2022.02.11
함수 선언문 vs 함수 표현식 vs 화살표 함수  (0) 2022.02.11
함수 return 으로 값 반환  (0) 2022.02.11
function 에 대하여  (0) 2022.02.11