JS strangeness

A

Aaron Gray

RobG said:
Aaron Gray meinte:


Dunno...

line 6:
var isIE = /*@cc_on!@*/false;

I guess it does that because shortly afterward it does:

var pushAll = function (set1, set2) {
for (var j=0, jL=set2.length; j<jL; j++) {
set1.push(set2[j]);
}
return set1;
};
if (isIE) {
pushAll = function (set1, set2) {
if (set2.slice) {
return set1.concat(set2);
}
for (var i=0, iL=set2.length; i<iL; i++) {
set1[set1.length] = set2;
}
return set1;
};
}

[...]
And why would one want to do something like that:

Because the author(s) do no know how to implement effective feature
detection?

How about:

var HTMLArray = function () {
// Constructor
};

...

if (isIE) {
HTMLArray = Array;
}
HTMLArray.prototype = [];
HTMLArray.prototype.each = function (functionCall) {


Which extends Array.prototype in IE with an each method, but in other
browsers extends a generic array object.


Yeah, there are bits of cruft in the code.

Aaron
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,141
Messages
2,570,814
Members
47,360
Latest member
kathdev

Latest Threads

Top