max fraguas
max fraguas

Reputation: 438

JS in Sublime Text 3 with Node.js Build system

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

Answers (2)

Narendra
Narendra

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

Grant
Grant

Reputation: 1994

According to another question/answer, it looks like you could do something like

console.log(Object.getOwnPropertyNames(Person.prototype))

Upvotes: 1

Related Questions