Use one javascript variable into another javascript file

Question

This is common.js

jQuery(function ($) {

    var commonJs = {
        init: function () {
        },
        showAlert: function () {
        },

    }

});

This is add.js

jQuery(function ($) {

    var addJs = {
        init: function () {
            console.log(commonJs.showAlert);
        },
    }

});

I want to use common js function commonJs.showAlert in add.js

How can i access that?

0
, , Shweta Danej 10 months 0 Answers 114 views 0

Leave an answer