Does Javascript's new operator do anything but make life difficult?

前端 未结 4 1392
粉色の甜心
粉色の甜心 2020-12-28 18:21

I come from the traditional web developer background where I can by no means claim to really know anything about Javascript, however I am trying.

I currently have wh

4条回答
  •  醉梦人生
    2020-12-28 19:11

    You brought up Crockford's "JavaScript: The Good Parts."

    New is a bad part. Page 114. I don't use it. (Well, almost never.)

    Crockford does use it (in his beget() method).

    Definitely don't use it when you can use something else. Create objects and arrays with object and array literals.

提交回复
热议问题