Node.js(화살표함수)

이정규 (가지마)·2023년 6월 3일
0

add1 , add2 , add3 , add4 는 같은 기능을 하는 함수 .

add2:add1을 화살표 함수로 나타낼수 있음.

function add1(x,y){
  return x+y;
}

const add2 = (x,y) => {  //중괄호다음에 바로 return이나오면 중괄호,return  생략가능. 
  return x+y;
}

const add3 = (x,y) => x+y;

const add4 = (x,y) =>(x+y);


function not1(x){
  return !x;
}

const not2 =x => !x;

화살표함수에서 this함수는 자기만의 this를가지고
function함수에서 this함수는 부모의 this를 가질수있어서 function함수가 살아있음.

profile
"꾸준함이 답이다."

0개의 댓글