ExtJS 3: Two ways of creating custom class: what's the difference?
问题 I'm trying to learn ExtJS and object-oriented JavaScript in general. I've seen people defining classes in custom namespaces in a couple of ways. What's the difference between these two methods? Method 1 Ext.ns('myapp.cars'); (function(){ var Car = Ext.extend(Object, { //... }) myapp.cars.Car = Car; })() Method 2 Ext.ns('myapp.cars'); myapp.cars.Car = Ext.extend(Object, { //... }); Method 2 is easier to read and requires less code; is there any reason Method 1 is better? Thanks! 回答1: It's