Posted By

remysharp on 07/24/07


Tagged

indexof


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

korzhik


Array.indexOf


 / Published in: JavaScript
 

Implements Array.indexOf for browsers that don't support the method.

  1. if (typeof Array.indexOf != 'function') {
  2. Array.prototype.indexOf = function(f, s) {
  3. if (typeof s == 'undefined') s = 0;
  4. for (var i = s; i < this.length; i++) {
  5. if (f === this[i]) return i;
  6. }
  7. return -1;
  8. }
  9. }

Report this snippet  

You need to login to post a comment.