我应该使用新的Type()或只是Type()调用构造函数 [英] Should I use new Type() or just Type() for calling a constructor
本文介绍了我应该使用新的Type()或只是Type()调用构造函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这两种语法都是等价的(至少我假设它们是)。
let o1 = new Object b
或
let o2 = Object()
你更频繁地使用哪种方式?
解决方案我喜欢使用新,除了它是我习惯于其他语言之外没有什么好的理由,它使得更容易findstr / grep的构造函数调用(缺乏智能工具来找到解决方案中的所有参考) 。
Both syntaxes are equivalent (at least I suppose they are).
let o1 = new Object()
or
let o2 = Object()
Which way do you use more often? What about readability issues?
解决方案
They are the same.
I prefer using 'new', with little good reason other than it is what I am accustomed to in other languages, and it makes it easier to findstr/grep for constructor calls (lacking smart tools to 'find all references' in a solution).
这篇关于我应该使用新的Type()或只是Type()调用构造函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文