Javascript Object compact()
// Compact (object) // ---------------- // Removes falsy values/keys Object.prototype.compact = function() { var key, compacted; compacted = {};//from www . ja v a 2s. c o m for(key in this) { if(this[key]) { compacted[key] = this[key]; } } return compacted; }