Last active
March 18, 2021 13:24
-
-
Save skrajewski/d33bfee3a1b31d0bb7c8ea42bcf113a6 to your computer and use it in GitHub Desktop.
Revisions
-
skrajewski revised this gist
Mar 18, 2021 . 1 changed file with 1 addition and 1 deletion.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 @@ -8,7 +8,7 @@ class Stack { } pop() { return this.stack.pop(); } } -
skrajewski created this gist
Mar 18, 2021 .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,17 @@ const stackA = new Stack(); stackA.push("abc"); stackA.push("xyz"); console.log(stackA.stack); stackA.stack = []; console.log(stackA.stack); const stackB = createStack() stackB.push("abc"); stackB.push("xyz"); console.log(stackB.stack); stackB.stack = []; console.log(stackB.stack); console.log(stackB.pop()); const stackC = createStack() console.log(stackC.pop()); 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,23 @@ class Stack { constructor() { this.stack = []; } push(el) { this.stack.push(el); } pop() { this.stack.pop(); } } const createStack = function () { const stack = []; const push = (el) => stack.push(el); const pop = () => stack.pop(); return { push, pop }; }