Javascript 'new' with function returning self

This question already has an answer here:

  • What is the 'new' keyword in JavaScript? 13 answers

  • In your particular instance, No, there is no difference.

    Eitherw way, your function will return a self defined Object. By invoking a function with the new keyword, ECMAscript will automatically create a new object for you (alongside doing some magic with prototype and constructor properties), which you might access / write to via this within the function (-constructor) .

    Again, your return { } call in that function, will always return exactly that object reference.

    链接地址: http://www.djcxy.com/p/40850.html

    上一篇: 什么是返回新函数(); 在JavaScript中?

    下一篇: 带有函数返回自我的Javascript'new'