Is there an equivalent of PHP's 'parent' with javascript prototypal inheritance?

前端 未结 2 1829
星月不相逢
星月不相逢 2021-01-14 07:59

I\'m using protypal inheritance and I would like to call an overridden method on the base class. In PHP I could do this using parent::functionName. Is this possible using Ja

2条回答
  •  迷失自我
    2021-01-14 08:04

    from my own best practices, best to create

    var parent = ...;
    

    when creating the object if reference to the parent is actually needed - which is not as much as one would expect. then use as desired.

    I personally think the term "objects" is misleading in reference to javascript since

    object == function == closure
    

    essentially giving the tools for an objectness without limiting to formal object / inheritance constraints. on the up side it makes a very fluid, mutable language; on the downside, you need to fill in yourself missing pieces when needed.

提交回复
热议问题