Reputation:
In jQuery core.js, currently, line 260
this.slice( i, +i + 1 );
is the "+i" statement a mistake or some fancy trickery I can't find any mention of?
Upvotes: 5
Views: 220
Reputation: 237975
It's a quick way to convert i
to a number. This matters because +
means something different if it is a string to if it is a number. For instance:
var i = "1";
console.log(i + 1); // "11"
console.log(+i + 1); // 2
It's basically a shortcut for parseInt(i, 10)
.
Upvotes: 14