Last active
December 9, 2015 20:58
-
-
Save v2e4lisp/4327466 to your computer and use it in GitHub Desktop.
get properties of an object;
This file contains hidden or 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
// get properties of an object; | |
// if f(property) is true; | |
var get_props_if = function (obj, f) { | |
f = f || function (arg) {return true;}; | |
var holder = []; | |
for (var p in obj) if (f.call(obj, p)) { | |
holder.push(p); | |
} | |
return holder; | |
} | |
console.log(get_props_if(p, {}.hasOwnProperty)); | |
console.log(get_props_if(a)); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment