Function Expression
//ES6
() => {}
//ES6
const getName = () => {}
When you receive parameters
//ES6
const getName = (name) => {}
const getName = name => {}
- Here, name is a parameter.
- When you receive only one parameter, you don't need ().
- When you receive more than one, you must use ().
//ES6
const getName = (name, age) => {}
return
//ES6
const hi = text => {
text += '하세요';
return text
};
- when the function merely returns, you need to put the value being returned next to the arrow like below.
//ES6
const hi = name => { return name };
const hi = name => name;