public
1 2 3 4 5 6 7 8 9 10 |
Ext.define('Student', { name : 'unnamed', getName : function(){ return 'Student name is ' + this.name; }, constructor : function(studentName){ if(studentName) this.name = studentName; } }); |
here you can access to name directly
1 |
studentObj.name |
private
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
Ext.define('Student', function(){ var name = 'unnamed'; return { constructor : function(name){ this.name = name; }, getName : function(){ alert('Student name is' + this.name); } }; }); //create an object of Student class var studentObj = Ext.create('Student','XYZ'); studentObj.getName(); |
here access to name only through getName()