In JavaScript, what are specific reasons why creating functions within a loop can be computationally wasteful?
问题 In JavaScript, what are specific reasons why creating functions within a loop can be computationally wasteful? On page 39 of JavaScript the Good Parts, Douglas Crockford states, "Avoid creating functions within a loop. It can be computationally wasteful". I can't seem to figure out why creating functions within a loop would be anymore wasteful than outside. 回答1: Because you're creating several Function objects instead of reusing just one. Example of creating an identical function... for (var