JavaScript bugs...
JavaScript in Safari really annoys me at times. Like, the fact that Safari doesn't have one of the most basic list iterating functions ever. Admittedly, it's only new to JavaScript - but that's why I hate JavaScript!
But now... I have written a JavaScript indexOf function for an array. And here it is:
First it checks if the function exists, and if not defines it. Sure it's slow, but you don't really do this much faster, unless you write it in C :-)
But now... I have written a JavaScript indexOf function for an array. And here it is:
if (!Array.indexOf) {
Array.indexOf = function (searchString) {
var i=0;
while (i<Array.length) {
if (steps[i]==searchString) return i;
i++;
}
}
}
First it checks if the function exists, and if not defines it. Sure it's slow, but you don't really do this much faster, unless you write it in C :-)


0 Comments:
Post a Comment
<< Home