Object.prototype.toString = function() { var r = "{", first = true for (var p in this) { if (!this.hasOwnProperty(p)) continue if (first) first = false else r += ", " r += p + ": " + this[p] } return r + "}" } Object.prototype.search = function(str, action) { for (var p in this) if (this.hasOwnProperty(p) && this[p].toLowerCase().indexOf(str.toLowerCase()) >= 0) action(this, p) } Stack = function(cards) { this.cards = cards } Stack.prototype.search = function(str, action) { for (var i = 0; i < this.cards.length; i++) this.cards[i].search(str, action) } s = new Stack([ { name: 'alex', car: 'honda civic' }, { name: 'takashi', car: 'toyota yaris' }, { name: 'yoshiki', car: 'toyota prius' } ]) s.search("toyota", function(obj, prop) { alert(obj + "." + prop + "=" + obj[prop]) })