Skip to content Skip to sidebar Skip to footer

Difference Between Prototype Structure Of Named And Anonymous Function In Javascript?

I am learning JS and came across the concept of Javascript. I also learned about two different ways of creating function //anonymous var fun1=function() { } //named

Solution 1:

Now my question is why the prototype of fun1() is pointing to Object

It's not. It is pointing to an object. Expand it and you will find that it's a normal prototype object, not the Object constructor.

prototype of fun2 is pointing to itself?

It's not. It is pointing to a normal prototype object as well. The only difference is that fun2 is a named function, so your console will display everything that has a .constructor == fun2 as "a fun2 object".

Post a Comment for "Difference Between Prototype Structure Of Named And Anonymous Function In Javascript?"