How can I define a default getter and setter using ECMAScript 5?

前端 未结 6 821
忘了有多久
忘了有多久 2020-12-07 01:14

How can I specify a default getter for a prototype? With default getter I mean a function that is called if obj.undefinedProperty123 is called.

I tried

6条回答
  •  鱼传尺愫
    2020-12-07 01:27

    I am not sure about what you are asking. But If you want a method to be called when the user attempts to Access object.nonExistingProperty . I dont think there is any way to do that.

提交回复
热议问题