0

All I have following code:

(function($,undefined){
    function Abc(){
      function sayHello(){
          console.log("I am Abc");
      }
    }
})(jQuery);

And my question is, how can I add more methods to Abc or overwrite sayHello? Thanks!

1 Answer 1

2

You can't. It's a local variable, private to that invocation of Abc. It cannot be overridden if Abc is written that way.

If you were actually making methods, perhaps like this:

function Abc() {
    this.sayHello = function() {
        console.log("I am Abc");
    };
}

Then you could extend and override it like so:

function Cba() {
    Abc.apply(this, arguments);
    this.sayHello = function() {
        console.log("I am Cba");
    };
}
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, icktoofay, got it. seems I have to find another way to extend jQuery FullCalendar.

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.