RosettaCodeData/Task/Stack/JavaScript/stack-2.js

9 lines
293 B
JavaScript

function Stack() {
this.data = new Array();
this.push = function(element) {this.data.push(element)}
this.pop = function() {return this.data.pop()}
this.empty = function() {return this.data.length == 0}
this.peek = function() {return this.data[this.data.length - 1]}
}