We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 52d08ce commit e47f27eCopy full SHA for e47f27e
chapter03/01-Stack2.js
@@ -0,0 +1,40 @@
1
+let _items = Symbol();
2
+
3
+class Stack2 {
4
5
+ constructor () {
6
+ this[_items] = [];
7
+ }
8
9
+ push(element){
10
+ this[_items].push(element);
11
+ };
12
13
+ pop(){
14
+ return this[_items].pop();
15
16
17
+ peek(){
18
+ return this[_items][this[_items].length-1];
19
20
21
+ isEmpty(){
22
+ return this[_items].length == 0;
23
24
25
+ size(){
26
+ return this[_items].length;
27
28
29
+ clear(){
30
31
32
33
+ print(){
34
+ console.log(this[_items].toString());
35
36
37
+ toString(){
38
+ return this[_items].toString();
39
40
+}
0 commit comments