kch*_*hak 8 javascript higher-order-functions
当我在第5章遇到这个时,我正在阅读Eloquent JavaScript:
你可以拥有创建新功能的功能.
Run Code Online (Sandbox Code Playgroud)function greaterThan(n) { return function(m) { return m > n; }; } var greaterThan10 = greaterThan(10);你可以拥有改变其他功能的功能.
Run Code Online (Sandbox Code Playgroud)function noisy(f) { return function(arg) { console.log("calling with", arg); var val = f(arg); console.log("called with", arg, "- got", val); return val; }; } noisy(Boolean)(0); //->calling with 0 //->called with 0 - got false
我的问题是: