[英]OO Javascript Calling method from another method of same object
I'm having trouble calling a method from within another method of the same object. 我在从同一对象的另一个方法中调用一个方法时遇到麻烦。
Any help on what I may be missing, or what to look for, would be greatly appreciated. 对于我可能会缺少的东西或要寻找的东西的任何帮助,将不胜感激。
var IceCream = function (flavor) {
this.tub = 100;
this.flavor = flavor;
};
IceCream.prototype = {
scoop : function () {
this.updateInventory; alert("scooping");
},
updateInventory : function () {
this.tub --;
alert(this.tub);
}
};
var vanilla = new IceCream("vanilla");
vanilla.scoop();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.