JSFiddle - React, Tailwind, and code Playground

by Sergio Kagiema

HTML

<script src="https://code.jquery.com/jquery-2.2.4.min.js"></script>

JavaScript

//What is the purpose of undefined - cannot 
//understand it after reading a couple of
//explanations - they are not clear enough
window.myApp = {};
					
(function (myApp, $, undefined) {

 		
		myApp.init = function (cb){
    
				this.initHello = function(name) {
        	
          if(!name) {
          	return;
          }
        	console.log('Hello '+ name);
        };
       
        //invoking inside the init??
        //is it necessary?
      console.log('This is ', this);
      this.initHello();  
        
      //is cb this necessary  
      if (cb) {
      	console.log('This is a callback ',cb);
        cb.call(this);
      }
     
		};
    
    $(function(){
	//my desired goal is to call
  //one function
  //the initHello
  //how can I achieve that
  //without invoking
  //myApp.init()
  myApp.init();
  console.log(window.myApp);
  //myApp.initHello('Sergio');
 
});
  
})(window.myApp, jQuery);