Last active
November 8, 2017 09:01
-
-
Save romaintailhurat/78d24c702ca3de47ebf53235546ec23f to your computer and use it in GitHub Desktop.
Revisions
-
romaintailhurat revised this gist
Nov 8, 2017 . 1 changed file with 0 additions and 15 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -18,18 +18,3 @@ class Stack { return resultingArray[0]; } } -
romaintailhurat created this gist
Nov 8, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,35 @@ /* Stack, array implementation http://www.cs.usfca.edu/~galles/visualization/StackArray.html */ class Stack { constructor() { this._stack = []; this._index = -1; } push(value) { this._index++; this._stack[this._index] = value; } pop() { const resultingArray = this._stack.splice(this._index, 1); this._index--; return resultingArray[0]; } } const st = new Stack() st.push(12); st.push(4); st.push(66); console.log(st); st.pop(); console.log(st); st.push("test"); console.log(st);