Here you can find the source of compact()
// refactored (requires Enumerable) Array.prototype.compact = function() { return this.select(function(value) { return value != null; });//from ww w . ja v a2 s . c om };
Array.prototype.compact = function() { var results = []; for (var i = 0, len = this.length; i < len; i++) { if (this[i] != null) { results.push(this[i]); return results; }; ...
Array.prototype.compact = function() { return this.filter(function(item) { return !!item; }); Object.prototype.compact = function() { var key, compacted; compacted = {}; for(key in this) { ...
Array.prototype.compact = function () { return this.filter((a) => a)
Array.prototype.compact = function() var a = []; for( var i = 0; i < this.length; i++ ) { if( i in this ) if( this[ i ] != "" ) a.push( this[ i ] ); return a; }; ...
Array.prototype.compact = function(){ var ca = []; for(var i in this){ if (this.hasOwnProperty(i)) { if ( present(this[i]) ) { ca.push(this[i]); return ca; };