johnuk
August 12, 2014, 9:53am
1
Hi all,
Just a curiosity really - is there a simple way of viewing the entire contents of a Function’s prototype object including user defined and default properties via Firebug?
I thought it would be as simple as say:
var derp = function(){};
derp.prototype;
and then clicking on the hyperlink in the left-hand pane but when I click on it, it just shows the constructor and none of the inherited stuff like like toString(), toSource() etc.
Any ideas? I hope that made sense
Try having a dig around in chrome’s web developer tools instead (F12).
Example:
var MyObject = function MyObject(){};
console.log(MyObject);
console.log(MyObject.prototype);
// Output
function MyObject(){}
MyObject
constructor: function MyObject(){}
arguments: null
caller: null
length: 0
name: "MyObject"
prototype: MyObject
__proto__: function Empty() {}
apply: function apply() { [native code] }
arguments: null
bind: function bind() { [native code] }
call: function call() { [native code] }
caller: null
constructor: function Function() { [native code] }
length: 0
name: "Empty"
toString: function toString() { [native code] }
__proto__: Object
<function scope>
<function scope>
Global: Window
__proto__: Object
__defineGetter__: function __defineGetter__() { [native code] }
__defineSetter__: function __defineSetter__() { [native code] }
__lookupGetter__: function __lookupGetter__() { [native code] }
__lookupSetter__: function __lookupSetter__() { [native code] }
constructor: function Object() { [native code] }
hasOwnProperty: function hasOwnProperty() { [native code] }
isPrototypeOf: function isPrototypeOf() { [native code] }
propertyIsEnumerable: function propertyIsEnumerable() { [native code] }
toLocaleString: function toLocaleString() { [native code] }
toString: function toString() { [native code] }
valueOf: function valueOf() { [native code] }
get __proto__: function __proto__() { [native code] }
set __proto__: function __proto__() { [native code] }