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?

3

1 Answer 1

1

You could try something like

if (typeof(ghost.method) != "undefined") {
    //method exists
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.