Last active
September 8, 2015 07:28
-
-
Save dnasca/7e4938fa10e1a67cf9f7 to your computer and use it in GitHub Desktop.
a contrived example of whats happening with the heap and stack. watch the call stack.
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 characters
| var heap = {}; | |
| var stack = []; | |
| var callFunction = function (nameFunc, args, lineNumber) { | |
| var func = heap[nameFunc]; | |
| var stackFrame = { | |
| funcy: func, | |
| name: nameFunc, | |
| args: args, | |
| env: {}, | |
| return: undefined | |
| }; | |
| stack.push(stack); | |
| var returnValue = func.apply(this, args); | |
| stackFrame.returnValue = returnValue; | |
| return stack.pop(); | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment