If I define the function as a variable object, then PhpStorm will show autocomplete for the item parameter.
var forEach = function(item) { if(item.type == 'label') { str += this.renderLabel(item.paramType); } if(item.type == 'input') { str += this.renderInput(item.paramType); } }; _.each(items,forEach,this);
If I write the same thing as the built-in parameter for the _.each() function. Then it will not work.
_.each(items,forEach, function(item) { if(item.type == 'label') { str += this.renderLabel(item.paramType); } if(item.type == 'input') { str += this.renderInput(item.paramType); } });
cgTag source share