1급 객체
자바스크립트에서 함수는 변수에 할당할 수 있다.
const foo = function() {
return 1;
}
객체의 프로퍼티에 함수를 할당할 수 있다.
const foo = {
getName: function() { return "John"; }
};
파라미터로 전달 할 수 있다.
function outer(inner) {
inner();
console.log("outer");
}
function inner() {
console.log("inner");
}
리턴 값으로 사용할 수 있다.
function foo() {
return function woo() {
console.log("woo");
}
}
위의 이유들로 자바스크립트에서 함수는 일급객체입니다.