new operator - JavaScript difference between function and new function -


The following JavaScript code is very confusing to me, can someone help me in my understanding? Why does not the person have prototype property?

  PersonX = function () {}; PersonY = new function () {}; Warning (PersonX.prototype); Warning (PersonY.prototype); a????    

  personality = function () {};   

Refers to the PersonX for an anonymous function. Indicates the PersonX function.

  PersonY = new function () {};   

A new creation of an unknown constructor works in the PersonY for example. PersonY indicates the object.


Regarding the prototype, PersonY has one, however, since no properties and methods were attached to the constructor nor immediately, there is a blank in it Prototype *.

You can actually check the prototype of PersonY by doing console.log . You will see that there is a prototype property in it (I see it in the __ proto __ chrome) which is "empty" but it has 2 hidden assets, constructor which constructs the constructor The function that creates the object, and the second __proto___ which takes you to the next "chain link" which is the object object

* Really is not empty because prototype is a series. This prototype level may be empty, but the next high prototype can be, or in this case, the properties and methods are there.

  object prototype - & gt; Constructor prototype - & gt; Your example would be: - toString () - empty - toString () - hasonproperty () - hasavanproperty () - and more ... and more ... - ... but nothing from the manufacturer    

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -