JSHint shows the error: "Function declared within loop referencing an outer scope variable may lead to confusing semantics". How can I improve the following code to get rid of the warning?
var getPrecedence = function getPrecedence(operator, operators) {
var keys = Object.keys(Object(operators));
for (var i = 0, len = keys.length; i < len; i++) {
var check = Object.keys(operators[keys[i]]).some(function (item) {
return item === operator;
});
if (check) return operators[keys[i]][operator];
}
};
operators. Not least becauseObject(operators)looks quite odd looks quite odd...{"^": {prec: 1, type: "op"}, "*": {prec: 2, type: "op"}, "log": {prec: 0, type:"fn"}, "(": {prec: 4, type:"open"}or so. (Although your structure for the brackets doesn't seem to fit in there anyway)