function BlackDog() {
this.name = "white";
return {
name : 'black',
bark : function(){
console.log(this.name + ' dog : 멍멍');
//black dog : 멍멍
}
}
}
function WhiteDog() {
this.name = 'white';
return {
name : 'black',
bark : () => {
console.log(this.name + ' dog : 멍멍');
//white dog : 멍멍
}
}
}
const blackDog = BlackDog();
const whiteDog = WhiteDog();
console.log("Black dog bark .... " )
blackDog.bark()
console.log("white dog bark ...." )
whiteDog.bark()
function twice(value){
return value*2;
}
//{}를 따로 열어 주지 않으면
//연산한 값을 그대로 반환한다는 의미
const triple = (value) => value * 3;
참고 : 리액트를 다루는 기술