Funarg problem

In some ways, the issue is how to deal with functions – traditionally the thought was to think of functions as stack based but how do we handle below situation:


function a{

var x = 20;

function b{ x = 10;}



Note that x hasn’t been passed as an argument.

Now, if functions are implemented as stacks , how do you push / pop the function state.

Solution is to use heap but it’s more expensive .