js함수
-
JS함수 정리 - 화살표함수, 즉시실행함수, 호이스팅, 타이머함수, 콜백프론트엔드 개발자가 될거야./js 2022. 6. 14. 11:17
* 화살표함수 // 화살표 함수 // () => {} vs function () {} const double = function (x) { return x + 2 } console.log('double: ', double(7)) const doubleArrow = x => x * 2 console.log('doubleArrow', doubleArrow(7)) // 화살표 함수 객체데이터 사용법 const doubleArrow = x => ({ name: 'jeongeun' }) console.log('doubleArrow', doubleArrow(7)) * 즉시실행함수 IIFE : 함수가 한 번 실행되고 쓸 일이 없을 때 : 이름이 없는 익명함수를 만들자마자 그 자리에서 바로 실행가능 // 즉시실행함수 ..