Class(),new Class和new Class()之间的区别 [英] Difference between Class(), new Class and new Class()
本文介绍了Class(),new Class和new Class()之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Class()
和新类
,新类之间有什么区别( )
?我做了一个测试,后来似乎做得更快。
What are the differences between Class()
and new Class
, new Class()
? I did a test and the later seems to do be quicker.
http://jsperf.com/object-initilzation
我读到没有区别,但似乎有。
I read there is no difference, but there appears to be.
推荐答案
Class()
调用函数。不要在构造函数上使用它。
Calls a function. Don't use this on constructor functions.
new Class
和new Class()
这些之间没有区别,都实例化一个新的实例一类。如果没有传递参数并且使用了 new
关键字,则parens是可选的。
There is no difference between these, both instantiate a new instance of a class. The parens are optional if there are no arguments being passed and the new
keyword is used.
这篇关于Class(),new Class和new Class()之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文