I'm fairly new to JavaScript beyond jQuery, and I was reading up on randomization in a JavaScript array & the shortcomings of using the Array.sort method with a random number. I see the recommendation instead is to use the Fisher-Yates shuffle. In looking at the JavaScript code for this method:
Array.prototype.randomize = function()
{
var i = this.length, j, temp;
while ( --i )
{
j = Math.floor( Math.random() * (i - 1) );
temp = this[i];
this[i] = this[j];
this[j] = temp;
}
}
I'm struck by this line:
var i = this.length, j, temp;
What's going on here? Is a variable being given multiple values, or is this shorthand for something?