0

Is there a possibility to implement rubylike ghost methods in Javascript?

The word ghost method means a method that doesn't really exist. If you call object.ghostMethod(), the Method isn't actually declared. There is a function called "method_missing()" in Ruby, which reacts to invocations to methods which aren't declared for the object.

Does a method similar to "method_missing()" exist in Javascript or is it possible to intercept all calls to a object?

GiCo
  • 566
  • 4
  • 19

1 Answers1

1

You could try something like

if (typeof(ghost.method) != "undefined") {
    //method exists
}