How are parameters handled when passing functions in Javascript? [duplicate]
问题 This question already has answers here : Higher-order functions in Javascript (4 answers) Closed 4 years ago . In http://eloquentjavascript.net/1st_edition/chapter6.html, there is the following example: function negate(func) { return function(x) { return !func(x); }; } var isNotNaN = negate(isNaN); alert(isNotNaN(NaN)); Knowing only basic Javascript and imperative programming, I am stumped by this programming style. Can someone help me to understand what happens during runtime. I stepped