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

后端 未结 6 539
天涯浪人
天涯浪人 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:21

    Its not a bad practice to overwrite the constructor when using prototypal inheritance. Infact many people do it like so:

    LolCat.prototype = {
        constructor: LolCat,
        hello: function () {
            alert('meow!');
        }
    };
    

提交回复
热议问题