0
var f = new function() {
   this.prop = '...';
};

console.dir(f); // Object

How it works? First is to determine the function and then call. But in this example, there is a call then determining. How it?

Aleksandr
  • 439
  • 3
  • 13
  • it's an anon constructor. calling `new` on a constructor function yields an object. – dandavis Sep 16 '15 at 21:51
  • After understanding how it works, make sure [to avoid this pattern](http://stackoverflow.com/q/10406552/1048572). – Bergi Sep 16 '15 at 21:51
  • @dandavis, I know it's constructor. I am interested in how it works? Call to function definition? Usually it is the definition of a constructor function and then call with the new. – Aleksandr Sep 16 '15 at 21:54
  • @Bergi, friend, do you speak russian? – Aleksandr Sep 16 '15 at 21:55
  • when you write "new Obj", "Obj" is the same stuff as the constructor function literal itself. therefore, you can interchangeably use a function literal in place of a function name in JS. – dandavis Sep 16 '15 at 21:56
  • @AleksandrAleksandrov: No, with that I cannot help. – Bergi Sep 16 '15 at 21:59
  • How in the world JavaScript called this pattern? – Aleksandr Sep 16 '15 at 22:01

0 Answers0