Reputation: 438
I'm executing JS code in sublime text 3 with Node 9.4.0 as build system. I would like to know why when I run:
function Person () { }
var manu = new Person();
console.log(Person.prototype)
I get:
Person {}
But when I run it from Chrome console, I get:
{constructor: ƒ}
constructor: ƒ Person()
__proto__: Object
How can I get Node to display the content of Person.prototype ?
Why does it display it empty?
Thanks for your answers.
Upvotes: 0
Views: 699
Reputation: 1529
Here no need to use "new" keyword you can run it as simple function.But for "new" keyword it will convert it as constructor hence Person.prototype is referring superior object which is window if you are running in console that convert it as constructure
For Exp:-
function Person () { }
var manu = new Person();
//var manu = Person();
Upvotes: 0
Reputation: 1994
According to another question/answer, it looks like you could do something like
console.log(Object.getOwnPropertyNames(Person.prototype))
Upvotes: 1