Jvascript class Stack
페이지 정보

본문
class Stack {
constructor() {
this.arr = [];
this.index = 0;
}
push(item) {
this.arr[this.index++] = item;
}
pop() {
if (this.index <= 0) return null;
const result = this.arr[--this.index];
return result;
}
}
- 이전글background-color-changer 24.03.27
- 다음글class Queue 24.03.26
댓글목록
등록된 댓글이 없습니다.