I wonder if you really need push to return the pushed value ... what's the use case and why would you need that ? ... cause things could be much easier and faster just using Array.
function StackMaker() {
var a = [];
a.isEmpty = StackMaker.isEmpty;
return a;
}
StackMaker.isEmpty = function () {
return this.length < 1;
};
You know and I know that Array already has a push method, I was just using this to demonstrate how to create a fully encapsulated data structure works, so yes for production purposes you'd go another way.
I wonder if you really need push to return the pushed value ... what's the use case and why would you need that ? ... cause things could be much easier and faster just using Array.
What do you think ?