Results 1 to 2 of 2

Thread: "New" vs. Ext.Create?

  1. #1
    Sencha User
    Join Date
    Nov 2007

    Default "New" vs. Ext.Create?

    I am currently porting a 3.4 app to 4.1 and have 100's of lines of code like

    var frmId = new Ext.form.field.Text({...});

    In Ext 4.x, these calls could be converted to:

    var frmId = Ext.create('Ext.form.field.Text',{...});

    I understand maybe the benefits of using Ext.define/Ext.create for application classes but why use Ext.create for Ext classes?

  2. #2
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Gainesville, FL


    Ext.create will instantiate the class just like the new keyword will except it checks to see if the class has already been loaded. If not then it will load the file. Once it has made sure the class definition exists then it will create the instance.

    If you know the class is going to be loaded, using the new keyword is fine, I do it about 99% myself.
    Mitchell Simoens @LikelyMitch

    Check out my GitHub:

    Posts are my own, not any current, past or future employer's.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts