mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 18:30:09 +00:00
added Array.prototype.compact() method...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
c1c470f661
commit
26d79e318e
@ -1112,9 +1112,17 @@ Object.get = function(obj, name, dfl){
|
||||
}
|
||||
|
||||
|
||||
// Compact a sparse array...
|
||||
//
|
||||
// NOTE: this will not compact in-place.
|
||||
Array.prototype.compact = function(){
|
||||
return list.filter(function(){ return true })
|
||||
}
|
||||
|
||||
|
||||
// like .length but for sparse arrays will return the element count...
|
||||
Array.prototype.len = function(){
|
||||
return this.filter(function(){ return true }).length
|
||||
return this.compact().length
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user