function numbering(a){
return a;
}
var add = function (x,y){
return x+y;
}
var add2 = (x,y)=>{
return x+y;
};
const add3 = (x,y)=>x+y;
var grades = {'egoing': 10, 'k8805': 6, 'sorialgi': 80};
var grades = {};
grades['egoing'] = 10
var grades = new Object();
const newObject = {
sayJS(){
console.log('JS')
},
sayNode,
[es + 6] : 'Fantastic'
}
객체와 배열로부터 속성이나 요소를 쉽게 꺼낼 수 있다.
var candyMachine = {
status:{
name : 'node',
count : 5,
},
getCandy : function(){
this.status.count--;
return this.status.count;
},
};
여기에서
var getCandy = candyMachine.getCandy;
var count = candyMachine.status.count;
를 쓰는 대신에
const {getCandy, status : {count}} = candyMachine;
로 간단하게 이용 가능하다.
배열에 대한 구조분해 할당도 존재.
const array = ['nodejs',{},10,true];
const [node,obj,,bool]=array;