[removed] Overwriting function's prototype - bad practice?

后端 未结 6 525
天涯浪人
天涯浪人 2020-12-13 00:51

Since when we declare a function we get its prototype\'s constructor property point to the function itself, is it a bad practice to overwrite function\'s prototype like so:<

6条回答
  •  时光说笑
    2020-12-13 01:26

    Its not a bad practice. But there is a simple and standard way of overriding a function like below. When ever we define a 'function LolCat()' globally, its created under window so you can always code like below.

    window.LolCat = function() {...};
    LolCat.prototype.hello = function () { ... }
    

提交回复
热议问题