[removed] The Good Parts - How to not use `new` at all

前端 未结 9 1939
迷失自我
迷失自我 2020-12-07 09:15

Crockford\'s book, JavaScript: The Good Parts, says (on page 114) that constructor functions should always be given names with an initial capital letter (i

9条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-07 09:41

    Not using new and blindly following Crockford is silly.

    Understand JavaScript and write good code. Using the new keyword is the Cornerstone of JavaScript OO.

    You are going to miss out on a lot of good JavaScript code by avoiding new.

    Rather than arbitrarily cutting huge chunks out of your toolkit, learn it and use it properly instead.

    Crockford has a habit of saying that anything in JavaScript which ever gave him a bug in his code is bad.

    I would personally go on to say that "[a]n even better coping strategy is to be competent."

提交回复
热议问题