0

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.

2 Answers 2

1

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

console.log(Object.getOwnPropertyNames(Person.prototype))
Sign up to request clarification or add additional context in comments.

Comments

0

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(); 

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.