1. const hello = function() {} : 익명적 함수를 만들어 변수에 할당
아래와 같이 함수를 변수 화하여 나타낼 수 있다.
const hello = function(){
console.log('hello');
};
console.log(hello);
[Running]
[Function: hello]
매개변수가 있더라도 크게 다르지 않다.
const hello2 = function(name){
console.log('hello', name);
};
const hello3 = function(name){
return `hello3 ${name}`;
};
'JavaScript' 카테고리의 다른 글
JavaScript기초(18)_함수(4) (0) | 2021.10.12 |
---|---|
JavaScript기초(17)_함수(3) (0) | 2021.10.11 |
JavaScript기초(15)_함수(1) (0) | 2021.10.09 |
JavaScrip기초(14)_반복문(2) (0) | 2021.10.07 |
JavaScript기초(13)_반복문(1) (0) | 2021.10.06 |
댓글