I have always used stack program as the first simplest example to express something new but powerful as previously I had shown Stack in Android App and now **Stack Program in Object Functional Programming language using Javascript**
I have always used stack program as the first simplest example to express something new but powerful as previously I had shown [Stack in Android App](https://rohansakhale.com/2012/03/17/Stack-Program-for-Android/) and now **Stack Program in Object Functional Programming language using Javascript**
Here we will need a node js server to run this program which is saved as js extension
In the following program, we created a closure of the Stack function and passed/called the messages like push, pop & print.
The var variables within Stack function are local to stack function and hence we can say this is an idiom for achieving the encapsulation principal of a class.
The `var` variables within Stack function are local to stack function and hence we can say this is an idiom for achieving the encapsulation principal of a class.
Since obj is the object here, so what if we say `obj.sp = 20;`
Since `obj` is the object here, so what if we say `obj.sp = 20;`
Don't worry, this will create a new variable inside obj table/object which will not affect the functionality of the closure that we are working onto i.e. Stack for now.