This repository was archived by the owner on Apr 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27.4k
forEach returns undefined for arrays begin do not with 0 #8510
Labels
Milestone
Comments
it's not super clear what you're saying, could you provide a reproduction? |
@ne3Vubeki - Perhaps you can start by updating this Plunker to show your problem: http://plnkr.co/edit/7B9cARoiM4Ti5DFTwLxA?p=preview |
In principle, everything is shown: |
okay, I see. You're right, this is the behaviour that Array.prototype.forEach would have, so it makes sense for us to do the same thing. I'll submit a patch u_u |
caitp
added a commit
to caitp/angular.js
that referenced
this issue
Aug 7, 2014
…ing properties) Array.prototype.forEach will not invoke the callback function if the properety is not present in the object. Because of this, we have the illusion of not iterating over non-added properties in a sparse array. From ECMAScript: 9. Repeat while k < len a. Let Pk be ToString(k). b. Let kPresent be HasProperty(O, Pk). c. ReturnIfAbrupt(kPresent). d. If kPresent is true, then i. Let kValue be Get(O, Pk) ... (steps for invoking the function and aborting if it throws) Closes angular#8510 Closes angular#8522
caitp
added a commit
to caitp/angular.js
that referenced
this issue
Aug 7, 2014
…ing properties) Array.prototype.forEach will not invoke the callback function if the properety is not present in the object. Because of this, we have the illusion of not iterating over non-added properties in a sparse array. From ECMAScript: 9. Repeat while k < len a. Let Pk be ToString(k). b. Let kPresent be HasProperty(O, Pk). c. ReturnIfAbrupt(kPresent). d. If kPresent is true, then i. Let kValue be Get(O, Pk) ... (steps for invoking the function and aborting if it throws) Closes angular#8510 Closes angular#8522
caitp
added a commit
to caitp/angular.js
that referenced
this issue
Aug 7, 2014
…ing properties) Array.prototype.forEach will not invoke the callback function if the properety is not present in the object. Because of this, we have the illusion of not iterating over non-added properties in a sparse array. From ECMAScript: 9. Repeat while k < len a. Let Pk be ToString(k). b. Let kPresent be HasProperty(O, Pk). c. ReturnIfAbrupt(kPresent). d. If kPresent is true, then i. Let kValue be Get(O, Pk) ... (steps for invoking the function and aborting if it throws) Closes angular#8510 Closes angular#8522
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Version 1.2.21
If we pass an array:
it forEach returns 'undefined', as cycle is inserted:
for( var i = 0 .....)
Previous versions properly treated such arrays.
The text was updated successfully, but these errors were encountered: