亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

javascript - js object-oriented
扔個(gè)三星炸死你
扔個(gè)三星炸死你 2017-06-26 10:58:46
0
4
720

Excuse me, what is the difference between adding or not adding parentheses to the mm function after new? Why do I get the same results?
Please ask a senior expert to explain the principle inside.

扔個(gè)三星炸死你
扔個(gè)三星炸死你

reply all(4)
大家講道理

First of all, for this kind of basic question, you need to learn to consult the official documentation.
The documentation has detailed instructions: new foo is equivalent to new foo(), which can only be used without passing any parameters.
Of course, you can’t completely trust the documentation. , after all, the pitfalls of js. .
Then what’s the difference? There are detailed descriptions in this
priority summary: new (with parameter list) has a priority of 19, and new (without parameter separation) has a priority of 18, so new foo() will be executed first

Finally, I remember seeing an article not long ago about a disgusting interview question, which was: new f(), new f, new f.g(), new f().g(), etc. Regarding the priority calculation problem, you can search it yourself

phpcn_u1582

Refer to MDN

new constructor[([arguments])]

When there is no need to pass parameters, the brackets () are optional

洪濤

var mm = function(val){

this.m = val

}
var a = new mm(1) ;
console.log(a)
var b = new mm ;
console.log(b)

過去多啦不再A夢

If the constructor does not require parameters, there is no difference between adding and not adding parentheses.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template