Hi currently I'm trying to get following snippet of code 开发者_开发问答to work:
function Entry() {
var pauses = new Array();
}
Entry.prototype = {
AddElement: function(aParameter) {
this.pauses.push(aParameter);
}
}
Unfortunately this code fails with following error in Safari if I try to call AddElement("Test");
TypeError: Result of expression 'this.pauses' [undefined] is not an object. Does anybody know why?
In your code, pauses is a local variable within the Entry() function, not a member on the object constructed by it.
You want to replace var pauses = ... with this.pauses = ....
change
var pauses = new Array();
to
this.pauses = new Array();
or, better
this.pauses = [];
加载中,请稍侯......
精彩评论