Skip to content

Instantly share code, notes, and snippets.

@v2e4lisp
Last active December 9, 2015 20:58
Show Gist options
  • Save v2e4lisp/4327466 to your computer and use it in GitHub Desktop.
Save v2e4lisp/4327466 to your computer and use it in GitHub Desktop.
get properties of an object;
// 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