1. Arrow Function, 함수 블록 사용, 파라미터 사용


Arrow Function

const add = function(one, two){
	return one + two;
};
console.log(add(1, 2));

const total = (one, two) => {
	return one + two;
};
console.log(total(1, 2));

함수 블록 사용

화살표 함수에서 함수 블록과 return 작성을 생략할 수도 있습니다.

⇒ 인자값이 1개일경우 괄호도 생략 가능합니다.

const total = (one, two) => one + two;
console.log(total(1, 2));//3
const total = (one) => { };
console.log(total(1)); //undefined
const point = (param) => ({book: param});
const result = point("책");
for( const key in result){
	console.log(key + ": "+result[key]);
};

[실행 결과]

book: 책

파라미터 사용

const get = param => param + 20;
console.log(get(10)); //30
const get = () => 10 + 20;
console.log(get());

2. 화살표 함수 구조, arguments 사용 불가


화살표 함수 구조