Skip to content

Instantly share code, notes, and snippets.

@alili
Last active November 22, 2016 07:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alili/711a04e9b75ed30b66ef075d33e2f9c0 to your computer and use it in GitHub Desktop.
Save alili/711a04e9b75ed30b66ef075d33e2f9c0 to your computer and use it in GitHub Desktop.
get properties and methods of an Object
function fun(name, age){
this.name = name || 'wonderful'
this.age = age || 18
}
fun.prototype.getName = function(){
return this.name
}
var me = new fun()
function getDetail(){
return {
properties:Object.getOwnPropertyNames(me),
methods:Object.getOwnPropertyNames(Object.getPrototypeOf(me))
}
}
console.log(getDetail(me))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment