Jvascript class Stack
페이지 정보
작성자 최고관리자 작성일 24-03-26 03:11 조회 1,418 댓글 0본문
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;
}
}
댓글목록 0
등록된 댓글이 없습니다.
