Posted By

tonic on 10/15/08


Tagged

search array find mootools


Versions (?)

Find string in array as value in mootools


 / Published in: JavaScript
 

You can find a string as an array row value. Ex: arr=['abcde','mdleo'] arr.find('dbd') -> array['abcde'] arr.find('akdowewo') -> array[] (empty)

  1. // NEEDS MOOTOOLS 1.2 FRAMEWORK
  2.  
  3. Array.prototype.find = function(searchStr) {
  4. var returnArray = [];
  5. this.each(function(objeto,index){
  6. if (objeto.contains(searchStr)) {
  7. returnArray.push(objeto);
  8. alert('hay uno');
  9. }
  10. });
  11. return returnArray;
  12. }

Report this snippet  

You need to login to post a comment.