ExtJs is the best way to check if Ext.Array is empty?
In ExtJS, using Ext.Array (after use Ext.Array.difference
) I am getting the resulting array and would like to know the best way to check if the array is empty?
I've used theArray.length
how this could be done in javascript, but I'm wondering if there is a better / faster way to achieve this? (At first I thought it isEmpty
would help, but it seems to be working on an object, not an array)
+3
Olivier painchaud
source
to share
1 answer
You can easily add this to the Array prototype like this:
Array.prototype.isEmpty = function(){
return !this.length;
};
var a = ['a','b','c','d'];
var b = ['b','d','f','h'];
var c = Ext.Array.difference(a,b);
var d = [];
console.log(c.isEmpty(), d.isEmpty());
Hope this helps :)
+2
Guilherme Lopes
source
to share