The Push and Pop method are built into javascript's array object.

Javascript – Stack

The push and pop method are built into javascript’s array object.

Sample

1
2
3
4
5
6
7
8
9
10
11
12
let todo = [];          // our todo stack

todo.push ("Mark-Lo-Pedia");

while (todo.length > 0) {
console.log (`Topics left to check=${todo.length}`);

let topic = todo.pop();
console.log (` Topic=${topic}`);
}

process.exitCode=0;

References