To define a custom class with constructor, add function name constructor as a class member:
Ext.define('Student', { name : 'unnamed', getName : function(){ return 'Student name is ' + this.name; }, constructor : function(studentName){ if(studentName) this.name = studentName; } });
Now you can create an object by passing parameter to the constructor:
var studentObj = Ext.create('Student','XYZ'); //or var studentObj = new Student('XYZ'); studentObj.getName(); //output: Student name is XYZ
Try it on https://fiddle.sencha.com/#fiddle/3kv