function Stack(){
this.dataStore = [];
this.top = 0;
this.push = push;
this.pop = pop;
this.peek = peek;
this.clear = clear;
this.length = length;
}
function push(element){
this.dataStore[this.top++] = element;
}
function pop(){
return this.dataStore[--this.top];
}
function peek(){
return this.dataStore[this.top-1];
}
function clear(){
this.top = 0;
}
function length(){
return this.top;
}
var a = new Stack();
a.push('alice');
a.push('ben');
a.push('jack');
a.push('lily');
console.log('length:' + a.length());
console.log(a.peek());
console.log(a.pop());
console.log(a.peek());
console.log('length:' + a.length());
console