Stack เป็น Abstract Data Type (ADT) ใช้ทั่วไปในภาษาโปรแกรมมิ่ง ชื่อว่า stack เพราะทำงานเหมือน stack จริง เช่น ไพ่หรือจานซ้อนกัน

Stack อนุญาตให้ดำเนินการที่ปลายเดียวเท่านั้น ทำให้เป็นโครงสร้าง LIFO (Last-In-First-Out) สมาชิกที่ใส่ล่าสุดจะถูกเข้าถึงก่อน ใน stack เรียกการใส่ว่า PUSH การนำออกว่า POP
แผนภาพแสดงการทำงานของ stack:

คลาส JavaScript สมบูรณ์สำหรับ Stack:
ตัวอย่าง
class Stack {
constructor(maxSize) {
if (isNaN(maxSize)) {
maxSize = 10;
}
this.maxSize = maxSize;
this.container = [];
}
display() {
console.log(this.container);
}
isEmpty() {
return this.container.length === 0;
}
isFull() {
return this.container.length >= this.maxSize;
}
push(element) {
if (this.isFull()) {
console.log("Stack Overflow!")
return;
}
this.container.push(element)
}
pop() {
if (this.isEmpty()) {
console.log("Stack Underflow!")
return;
}
this.container.pop()
}
peek() {
if (isEmpty()) {
console.log("Stack Underflow!");
return;
}
return this.container[this.container.length - 1];
}
clear() {
this.container = [];
}
}