JavaScript Equivalent Of PHP __call

前端 未结 5 1368
一生所求
一生所求 2020-12-05 09:55

In PHP you can detect when a method is called even when it doesn\'t exist using the \"magic\" __call function.

public function __call($methodNam         


        
5条回答
  •  死守一世寂寞
    2020-12-05 10:23

    Although it's not an elegant way as we've already deduced that JavaScript does not have a __call, method_missing, __getattr__ it is possible to create combinations of properties to create concrete functions that relay to a single method, passing along the properties that were used to create it.

    One example is Myriad.js.

提交回复
热议问题