화살표 함수 ES6 신 문법
function add (x,y) {
return x + y ;
}
1-1 . 기본적인 화살표 함수
let arrowFunc01 = (x,y) => {
return x + y ;
}
1-2. 한 줄로
let arrowFun02 = (x,y) => x + y // 중괄호 안의 내용이 한 줄이면 이렇게 쓸 수 있다.
console.log(arrowFun02(1,2)); // 3
function testFunc(x) {
return x;
}
화살표 함수로
let arrowFun03 = (x) => x;
일반 함수 const add = function(a,b) { return a+b; } function 삭제 const add = (a, b) => { return a + b; } return이 한 줄인 경우 중괄호, return 삭제 const add = (a, b) => a + b;