Search code examples
javascriptglobal-variablessapui5

How to declare global variables without using window object in sapui5


I have followed many examples and none are getting me a result.

Thanks in advance


Solution

  •        onInit : function(){
               $.sap.myVar = "console this";
           },
    
           someFunction : function(){
               console.log($.sap.myVar);
           }
    

    //By declaring like this you can access the variable through out the application