JavaScript #4 - arrow function

Haebin Ethan Jeong·2020년 7월 22일
0

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;
profile
I'm a Junior studying Economics and Computer Science at Vanderbilt University.

0개의 댓글