화살표 함수 (Arrow Function)
기존의 자바스크립트 함수 정의 방식
let a = function () {
// ...
};
let a = () => {
//...
};
()=> {
print();
log();
return 10+20;
};
복잡한 자바스크립트 선언문이 들어갈 경우에는 {}를 사용하여 구현
() => {
print();
log();
return 10+20;
};
인자를 1개만 선언하는 경우 인자를 받을 때 사용하는 소괄호()를 생략가능
const a = num => {
return num * 10;
};
const b = num => num * 10;
a(10); //100
b(10); //100
const Foo = () => {};
const foo = new Foo(); // Uncaught TypeError: Foo is not a constructor