Syntax
--n reduces the variable. A little more common that you may have seen is n++ , which seems to be, but increases the variable.
-- or ++ can appear before or after a variable, and there is a subtle difference. When it comes earlier, it changes the value and then returns the changed value. When this happens, it returns the original value. When using a value directly, it matters.
var i; // affix i = 1; console.log(i++, i) // 1 2 i = 1; console.log(i--, i) // 1 0 // prefix i = 1; console.log(++i, i) // 2 2 i = 1; console.log(--i, i) // 0 0
Notice how the value of the prefix increment or decrement expression returns the same value for i after an operation where there is no affix version.
So, a long story, JSLint really dislikes the prefixes of increment operators. But this should be equivalent:
while ( i >= 0 ) { i -= 1; this.removeEventListener( types[i], handler, false ); }
Without using the direct result of the decrease operation, it ceases to matter how this operator works and what it returns. It is also a little more explicit, and JSLint loves explicitly.
source share