Image

Imagevictorgr wrote in Imagewebdev

Catch undefined method calls in JS

Hi!

There is an interesting task. I need to catch any undefined calls in my JS code. Is there a solution?

Imagine:
    function a() {
        alert('Hi, I'm a function!');
    }

    a(); // works great

    a.b(); // call undefined function


So, are there any ways to catch calls a.b() in my function a()?