Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

doesNotUnderstand for JavaScript?

Is there a way to simulate Smalltalk's doesNotUnderstand or Ruby's method_missing in Javascript?

like image 572
Richard Durr Avatar asked Oct 15 '25 14:10

Richard Durr


1 Answers

There is no catch-all method defined in the JavaScript standard, but Mozilla implements the non-standard __noSuchMethod__ for SpiderMonkey and Rhino (including Firefox obviously).

You may also be interested in checking out @CMS' answer given to the following Stack Overflow question:

  • Is there an equivalent of the noSuchMethod feature for properties, or a way to implement it in JS?
like image 169
Daniel Vassallo Avatar answered Oct 17 '25 02:10

Daniel Vassallo