One of the warnings that JSLint (and JSHint) can output is “Don’t make functions within a loop”. JSLint doesn’t provide any further information about the warning and a quick web-search only results in mentions of best-practice and wasting of resources. I preferred to see actual stats so I wrote up a small test using JSLitmus to benchmark the difference between defining a function inside a loop, outside a loop, outside a function and outside a function with a local reference. I’m not sure why Chrome suffers a drastic performance decrease when using a local reference to a global function but at least this provides some solid data for obeying the warning:
