I can’t figure out how this works.. but it does.
function toString() {
var t = ”;
for (var i in this) {
if (typeof(this[i]==’function’)) continue;
t += i+’ = ‘+this[i]+’n’;
}
return t;
}
BrowserInfo.prototype.toString = toString;
var oBrowser = new BrowserInfo();
*******************************************
Heres what I can figure out. So theres a function called browser info.. and the new toString() function overwrites the default toString function. This new toString function just outputs the entire function in a string. The lines that I dont understand are
for (var i in this) {
if (typeof(this[i]==’function’)) continue;
t += i+’ = ‘+this[i]+’n’;
}
Doesnt var i have to be defined somewhere.. and how can you check whether its equal to ‘function’. Why would they use typeof(this[i]==’function’) instead of just (this[i]==’function’).
Javascript shouldnt be this confusing right? ?