/ 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)
Ex:
arr=['abcde','mdleo']
arr.find('dbd') -> array['abcde']
arr.find('akdowewo') -> array[] (empty)
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
// NEEDS MOOTOOLS 1.2 FRAMEWORK Array.prototype.find = function(searchStr) { var returnArray = []; this.each(function(objeto,index){ if (objeto.contains(searchStr)) { returnArray.push(objeto); alert('hay uno'); } }); return returnArray; }