I have a library with the following addition for Array types -
Array.prototype.top = function() {
return (this.length > 0) ? this[this.length-1] : null;
}
It seems to be applied to non-Array objects - e.g.,
for (key in myrecordset) {
alert(key); // will iterate and alert "top";
}
In the debugger console:
> myrecordset.length
< undefined
> typeof myrecordset
< 'object'
> myrecordset instanceof(Array)
< false
> myrecordset['top']
< f() {
return (this.length ...
}
So, what the ? The object is not a javascript array (ie, no length, not an instance of, ...) but the Array.prototype.top seems to have been applied?
Note: in addition, trying to follow the prototype chain I get
> myrecordset.constructor()
< {}
[[ Prototype ]]: Object

myrecordsetis. Please, answer a simple question: What happens if you callmyrecordset['top']()? (Iflenghtis undefined...)Object.getPrototypeOf(myrecordset);or just logmyrecordsetand follow the[[Prototype]]internal slots to follow the prototype chain, not.constructor()myrecordset.