FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
javascript-datastructures-algorithms/stack-array.js at master · allonsmandy/javascript-datastructures-algorithms · GitHub
allonsmandy
/
javascript-datastructures-algorithms
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
7
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
javascript-datastructures-algorithms
/
stack-array.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
45 lines (35 loc) · 644 Bytes
Breadcrumbs
javascript-datastructures-algorithms
/
stack-array.js
Copy path
File metadata and controls
45 lines (35 loc) · 644 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
class
Stack
{
constructor
(
)
{
this
.
items
=
[
]
;
}
push
(
element
)
{
this
.
items
.
push
(
element
)
;
}
pop
(
)
{
return
this
.
items
.
pop
(
)
;
}
peek
(
)
{
return
this
.
items
[
this
.
items
.
length
-
1
]
;
}
isEmpty
(
)
{
return
this
.
items
.
length
===
0
;
}
size
(
)
{
return
this
.
items
.
length
;
}
clear
(
)
{
this
.
items
=
[
]
;
}
}
const
stack
=
new
Stack
(
)
;
console
.
log
(
stack
.
isEmpty
(
)
)
;
//true
stack
.
push
(
5
)
;
stack
.
push
(
8
)
;
console
.
log
(
stack
.
peek
(
)
)
;
//8
stack
.
push
(
11
)
;
console
.
log
(
stack
.
size
(
)
)
;
//3
console
.
log
(
stack
.
isEmpty
(
)
)
;
//false
stack
.
push
(
15
)
;
stack
.
pop
(
)
;
stack
.
pop
(
)
;
console
.
log
(
stack
.
size
(
)
)
;
//2
Back
|
FazBrowse Home
|
New Git URL