javascript에서의 함수가 일급객체인 이유
ex)
var func = function (fun) {
return function () {}
}
var fun = function () {}
func(fun)
고차함수란 함수를 리턴 값으로 뱉는 것
const points = [40, 100, 1, 5, 2, 25, 10];
points.sort(function (a, b) { return a - b; });
console.log(points); // [ 1, 2, 5, 10, 25, 40, 100 ]
points.sort(function (a, b) { return b - a; });
console.log(points); // [ 100, 40, 25, 10, 5, 2, 1 ]
sort가 돌아가는 원리 다시 보기