웹 실습

함수 arrow function 유의점1

life... 2022. 4. 5. 17:39

const item1=100;

const itme2=200;

일반 함수

showprice1(item1)

 

const showprice1=function(a) {

       console.log(a+loyalty);

}

 

 

arrow function으로 나타내려면

 

const showprice2 =( a) =>{

       console.log(a+loyalty);

}

 

showprice2(item2);

//함수선언 후!!

 

arrow function 유의점:

1.

arrow function은

항상 실행부분은 항상 선언한곳의 아래여야한다.

일반 function은 선언전,후 모두 사용 가능하다.