开发者

Javascript multidimensional object with unexpected properties

Working in javascipt, I'm initialising a multi dimensional object (which itself is nested several Objects deep). However, when looking at the properties of the child object it has unexpected properties, the first one being "fromBase64". This happens when using the IE6 browser and the TIBCO GI framework, but the object is independent of any GI specific classes.

I have no idea where this property has come from. Could anyone shed any light?

orderProfiles.product = function(productParameters){
    this.property1 = productParameters['property1'];
    this.property2 = productParameters['property2'];
    ...
    this.childrenProducts = new Object();
};

Then

for (child in window.selectedProducts[contact][product]['childrenProducts']){
    alert("child = " + child);
}

Gives

child = fromBase64
child = toBase64
child = constrainLength
child = endsWith
child = urlTo
child开发者_JAVA百科 = toAbsolute
child = doTruncate
child = escapeHTML
child = doReplace
child = trim
child = fromBase64


Use hasOwnProperty to differentiate between your own properties and those you inherited from the Object constructor (which may have been extended):

var childrenProd = window.selectedProducts[contact][product].childrenProducts;
for (child in childrenProd){
  if (childrenProd.hasOwnProperty(child)){
    alert("child = " + child);
  }
}


Those all look to be methods that prototype.js has extended objects with. Try removing prototype.js and take it from there.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜