"method_missing" for javascript

Discussion in 'Javascript' started by pedz, Jul 28, 2011.

  1. pedz

    pedz Guest

    Is there a way to implement a type of "method_missing" concept that Ruby has? Or, equally likely, a javascript way of fulfilling the same need.

    The method_missing method defined for object foo is called when foo.whatever(args) is called and whatever is not defined. The method is passed the name (whatever in this case) along with args.

    Obviously I can define a function call blah and then instead of calling foo.whatever(args), I can call foo.blah("whatever", *args) but the "blah" is distracting in this case. I'm wondering if there is a way to make the "blah" not be needed.

    Thank you,
    pedz
     
    pedz, Jul 28, 2011
    #1
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.