Is JavaScript's “new” keyword considered harmful?

前端 未结 12 2077
情书的邮戳
情书的邮戳 2020-11-21 23:18

In another question, a user pointed out that the new keyword was dangerous to use and proposed a solution to object creation that did not use new.

12条回答
  •  自闭症患者
    2020-11-21 23:49

    I think "new" adds clarity to the code. And clarity is worth everything. Good to know there are pitfalls, but avoiding them by avoiding clarity doesn't seem like the way for me.

提交回复
热议问题