View Full Version : How do I extend an Array?

26 Apr 2013, 6:16 AM
I'm attempting to extend an Array, using this code:

extend: 'Array',
init: function(application){

top: function(){
if(this.length == 0){
return null;
return this[this.length -1];

But I keep getting this error:

TypeError: controller.doInit is not a function

What is the correct way to do this? Thanks.

26 Apr 2013, 11:26 AM
You can extend classes there were Ext.define'd, but not native JS classes.

I'd recommend in your case using the Ext.util.MixedCollection class which is a beefed up array.

It has the last method, same as top in your example.