Here you can find the source of flatten()
Object.prototype.flatten = function() { var that = this; return Object.getOwnPropertyNames(this).map(function(name) { return that[name]; });/*from w ww. j a v a 2s . co m*/ };