JSLint: control comments (selective ignore)

Put /*ignore jslint start*/ before and /*ignore jslint end*/ after the code to be ignored. Ex: function ignore(){ /*ignore jslint start*/ var x; var y; /*ignore jslint end*/ } Or export JsLint settings, define your IgnoreErrorStart/ IgnoreErrorEnd symbols and import. Edit Some folks may confuse this answer with JSHint. In that case, use these: /*jshint … Read more

Don’t make functions within a loop [duplicate]

Move the function outside the loop: function dummy() { return this.name_; } // Or: var dummy = function() {return this.name;}; for (var i = 0; i<processorList.length; ++i) { result[i] = { processor_: timestampsToDateTime(processorList[i]), name_: processorList[i].processorName, getLabel: dummy }; } … Or just ignore the message by using the loopfunc option at the top of the … Read more

JSlint error ‘Don’t make functions within a loop.’ leads to question about Javascript itself

Partially it depends on whether you’re using a function expression or a function declaration. They’re different things, they happen at different times, and they have a different effect on the surrounding scope. So let’s start with the distinction. A function expression is a function production where you’re using the result as a right-hand value — e.g., … Read more

tech