How to get an object's methods?

前端 未结 12 1162
暗喜
暗喜 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:47

    The methods can be inspected in the prototype chain of the object using the browser's developer tools (F12):

      console.log(yourJSObject);
    

    or more directly

      console.dir(yourJSObject.__proto__);
    

提交回复
热议问题