Search code examples
javascriptmootools

MooTools - Object.contains with wildcard


I want to search for a value in an Object. For example: I am searching for "boy". In the Object there is a value of "boy1" but Object.contains doesn't return true. Only when I actually search for "boy1".

Is it possible to use wildcards or is there any other function?

if(Object.contains(object, 'boy')) {
  console.log("FOUND!");
}

Solution

  • I had found the answer by myself:

    Object.each(arrayWithObjects, function(object, index) {                                                                                                                                      
       Object.each(object, function(value, key) {                                                                                                                                   
           if(value.indexOf(searchTerm) > -1) {                                                                                                                                  
               foundContacts.push(object);                                                                                                                                  
           }                                                                                                                                                                     
       });                                                                                                                                                                           
    });