자바스크립트 함수에 대한 설명

 

함수 종류는 3가지이다.

1. function declarations

function add(x,y){
  return x+y;
}

2. function expressions

const calculation = function() {
}

 함수 표현식(2번)은 함수 선언식(1번) 대비 함수 중복 선언을 막아주는 중요한 유틸성이 있다.

 

3. function method

const calculation = {
	add: function(){
    }
}

4. arrow function

const add = (x,y) => x + y;

화살표 함수는 다른 함수와는 몇가지 부분이 다르다. 다른 함수방식과 비교시 가볍지만 argument가 없고, this의 작동 방식이 다르다고 한다.

'자바스크립트' 카테고리의 다른 글

Ternary operator(삼항연산자)  (0) 2022.06.15
앞으로 공부방법  (0) 2022.05.19
Object  (0) 2022.04.14
EventListener  (0) 2022.04.13
parseInt, string and number  (0) 2022.04.12

+ Recent posts