i have this declaration of an object inside an Angular.js module:
$scope.Stack = function () {
this.top = null;
this.size = 0;
};
And when i call push method of that object i get undefined error:
$scope.Stack.push = function (data) {
return this.size;
};
Why?
Pushmethod is defined for anarray. You should learn arrays and how to push data in an array.thisproblem in JavaScript. Thethisinstance when you are calling thepushmethod is not thethisthat you are expecting. How are you callingpush? Please provide more code.