Methods that declare an object directly in js

  • 2020-03-30 03:41:26
  • OfStack

var ctrl = { 
init: function(){ 
this.a(); 
this.b(); 
}, 
name : "zs", 
a: function(){ 
alert("aa"); 
}, 
b: function(){ 
alert("bb"); 
} 
}; 
var str = ctrl.name; 
console.info(str); //zs 
ctrl.init(); // The pop-up aa,bb

Related articles: