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 file:

/*jshint loopfunc:true */

Leave a Comment