function Stack () { this.Items = null; this.push = function (item) { item.NextItem = this.Items; this.Items = item } this.pop = function () { if (this.Items == null) return null; var item = this.Items; this.Items = item.NextItem; item.NextItem = undefined; return item; } this.toString = function () { var s = new String("STACK DUMP:\n"); var item = this.Items; while (item) { s += ("{" + item.toString() + "}\n"); item = item.NextItem; } return s; } }