Merge two option-objects with function Code Answer

Hello Developer, Hope you guys are doing great. Today at Tutorial Guruji Official website, we are sharing the answer of Merge two option-objects with function without wasting too much if your time.

The question is published on by Tutorial Guruji team.

I plan to merge two objects that contain methods:

var options = {
    show: function() {
        console.log(1);
    }
}

var options2 = {
    show: function() {
        console.log(3);
    }
}

options = $.merge(options, options2);

But if I do console.log(options.show) I recieve only first array.

My question is, how to merge options array with options2?

Answer

You can call the oher function inside the first function block

var options = {
    show: function() {
        console.log(1);
        options2.show();
    }
}

var options2 = {
    show: function() {
        console.log(3);
    }
}

options.show();
We are here to answer your question about Merge two option-objects with function - If you find the proper solution, please don't forgot to share this with your team members.

Related Posts

Tutorial Guruji