Missing support for JavaScript indexOf()

Forums » Opera for mobiles/devices » Opera for Nintendo DS/DSi

You need to be logged in to post in the forums. If you do not have an account, please sign up first.

Go to last post

7. May 2010, 11:24:33

Arty2

Posts: 5

Missing support for JavaScript indexOf()

Looks like it was unsupported by Opera's JS engine when it launched, though 10.5+ does support it, which made me scratch my head for a couple of days.
Test case: http://www.youtube.com/watch?v=dTDYWQFCSD0&feature=related

You can add support using a protype however, like the following one:

Originally posted by http://www.dustindiaz.com/basement/sugar-arrays.html:

Array.prototype.indexOf = function(el, start) {
    var start = start || 0;
    for ( var i=0; i < this.length; ++i ) {
        if ( this === el ) {
return i;
}
}
return -1;
};



Perhaps this might prove helpful to someone.

Forums » Opera for mobiles/devices » Opera for Nintendo DS/DSi