How to get an object's methods?

前端 未结 12 1146
暗喜
暗喜 2020-12-13 03:33

Is there a method or propertie to get all methods from an object? For example:

function foo() {}
foo.prototype.a = function() {}
foo.prototype.b = function()         


        
12条回答
  •  执念已碎
    2020-12-13 03:54

    In Chrome is keys(foo.prototype). Returns ["a", "b"].

    See: https://developer.chrome.com/devtools/docs/commandline-api#keysobject

    Later edit: If you need to copy it quick (for bigger objects), do copy(keys(foo.prototype)) and you will have it in the clipboard.

提交回复
热议问题