Created
November 20, 2013 17:41
-
-
Save adrianvlupu/7567589 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function scan(obj, search, from) | |
{ | |
var k; | |
if (obj instanceof Object) { | |
for (k in obj){ | |
//console.log('object ', obj, k); | |
if (obj.hasOwnProperty(k)){ | |
if(k.toString().indexOf(search)!=-1){ | |
console.log('found string as prop ', k, obj); | |
}else{ | |
if(!from) from=obj; | |
scan(obj[k], search, from); | |
} | |
} | |
} | |
} else { | |
if(obj!=null && obj.toString().indexOf(search)!=-1){ | |
console.log('found string as value ', obj, from); | |
} | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment