DOM, if not WONTFIX -- forEach just wants to make sure there's a .length property, and then it runs on every property that's present between 0 and .length - 1, inclusive. (I do wonder where it's finding .length, though!)
Assignee: general → nobody
QA Contact: general → general
The iframes are window, window, etc. Does it makes sense that the script in comment 0 is equivalent to running forEach over the global (window) object?
Yes, a function applied to null gets the global object. Still wonder where length is coming from, kinda -- maybe some DOM0 hangover?
I don't think this is a bug. Array.generic(t, ...) is *intended* to be equivalent to Array.prototype.generic.call(t, ...).
It makes sense to be able to use window.frames.length, window.frames, etc. But window.frames is the same as window, so these also show up as window.length, window, etc.
Status: NEW → RESOLVED
Last Resolved: 11 years ago
Resolution: --- → INVALID
One thing that irks me: Just because this method is meant to be similar to Array.prototype.forEach.call(null) doesn't mean we have to keep the crazy, non-intuitive, non-deterministic quirks associated with it. To me acceptable solutions would be: - Do nothing (ignore the null, don't loop). - Throw an exception (it's not an object, don't treat it as such).
What's non-deterministic about it? Are you seeing behaviour that varies from call to call, or based on changes that aren't used as specified inputs or outputs? null isn't an object when it's used in call or apply either, how would the inconsistency be justified? When you all a function without an explicit this, you get the global object -- for all cases on the web that I know of. The gotcha here is that window looks like an array, when it has frames, because of the DOM0 hangover. I don't recommend changing that, either.
I've started a follow-up discussion on the ECMAScript 4 mailing list: https://mail.mozilla.org/pipermail/es4-discuss/2008-March/002472.html
You need to log in before you can comment on or make changes to this bug.