das haar in der suppe #
stell dir vor du sitzt vorm computer und hast dein javascript erweiterungs-library nicht zur verfügung …
ja, genau: die frisur ist zersaust, der array nicht und ob obiger titel zutrifft, läßt sich auf die schnelle auch nicht sagen.
// shuffle
Array.prototype.shuffle = function() {
for (var j,x,i = this.length; i;
j = parseInt(Math.random()*i),
x = this[--i], this[i] = this[j], this[j] = x);
}
// in_array like method
Array.prototype.contains = function(el) {
for (var i = 0; i < this.length; i++)
if (this[i] == el) return true;
return false;
}
/* Usage:
var a = new Array('a', 'c', 'd', 'f');
if (a.contains('b')) alert('Yeah! Beh');
a.shuffle();
alert(a.toString());
*/
heutzutags ist dieses post mindestens einen ajax-tag wert.
