Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
class Queue
class Queue { constructor() { this.values = []; } add(value) { this.values.push(value) } remove() { return this.values.shift(); } peek() { return this.values[0]; } isEmpty() { return this.values.length === 0; } } let queue = new Queue(); console.log(queue.isEmpty()); queue.add(3) queue.add(4) console.log(queue.peek()); console.log(queue.isEmpty()); console.log(queue.remove()); console.log(queue.isEmpty());
run
|
edit
|
history
|
help
0
Please
log in
to post a comment.
rstring
p
a pipeline generator
Objects
single_digit
binary
LazyListJS
Probability
Strange Attractors
ArraY_ROW addition
Please log in to post a comment.