MCPcopy
hub / github.com/trekhleb/javascript-algorithms / peek

Method peek

src/data-structures/stack/Stack.js:22–30  ·  view source on GitHub ↗

* @return {*}

()

Source from the content-addressed store, hash-verified

20 * @return {*}
21 */
22 peek() {
23 if (this.isEmpty()) {
24 // If the linked list is empty then there is nothing to peek from.
25 return null;
26 }
27
28 // Just read the value from the start of linked list without deleting it.
29 return this.linkedList.head.value;
30 }
31
32 /**
33 * @param {*} value

Callers 1

Stack.test.jsFile · 0.45

Calls 1

isEmptyMethod · 0.95

Tested by

no test coverage detected