반응형

1. return은 반드시 함수로 해야한다.

2. 함수 호출은 직접 하면 안되고 변수에 담아서 해야함 ( x fnA()     o const result = fnA(); )

 

 

const fnA = () => {
  let var1 = 1; 
 
  const increase = () => var1++;
  return increase;
}

const add1 = fnA();
console.log(fnA());
console.log(add1());
console.log(add1());
console.log(add1());
console.log(add1());
// console.log(fnA());

 

 

ƒ increase()length:0name:"increase"[[Prototype]]:ƒ ()length:0name:""arguments:"Error: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them"caller:"Error: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them"constructor:ƒ Function()apply:ƒ apply()bind:ƒ bind()call:ƒ call()toString:ƒ toString()[[Prototype]]:{}
1
2
3
4
반응형

+ Recent posts