Timeline for Using forEach method in javascript
Current License: CC BY-SA 3.0
15 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Jun 19, 2013 at 11:55 | comment | added | Maizere Pathak.Nepal | @nnnnnn forEach() method doesn't work for the object u mentioned | |
| May 15, 2013 at 7:07 | vote | accept | Maizere Pathak.Nepal | ||
| Apr 15, 2013 at 9:35 | comment | added | Quentin | @Maizere — It can't. It operates on array-like objects. | |
| Apr 15, 2013 at 9:33 | comment | added | Maizere Pathak.Nepal | @Quentin since it is designed invoke func for the element of an array how can it invoke function for the object with string key | |
| Apr 15, 2013 at 9:28 | vote | accept | Maizere Pathak.Nepal | ||
| Apr 15, 2013 at 9:56 | |||||
| Apr 15, 2013 at 9:27 | comment | added | Maizere Pathak.Nepal | @Quentin that will be too complicated | |
| Apr 15, 2013 at 9:24 | comment | added | Quentin |
@Maizere — No, but you have to do something to set this (inside the forEach function) to be the array-like object you want to operate on.
|
|
| Apr 15, 2013 at 9:23 | comment | added | Maizere Pathak.Nepal | @nnnnnn is the use of call and apply compulsory for arry-like objects | |
| Apr 15, 2013 at 9:18 | comment | added | nnnnnn |
@Maizere - No, any array-like object, e.g., it would work on this object: {"0":10,"1":20,"length":2}.
|
|
| Apr 15, 2013 at 9:16 | history | edited | Quentin | CC BY-SA 3.0 |
added 70 characters in body
|
| Apr 15, 2013 at 9:16 | comment | added | Maizere Pathak.Nepal | @Quentin i agree too, with the use of call and apply it works but is it only for Nodelist? | |
| Apr 15, 2013 at 9:14 | comment | added | Denys Séguret | @Quentin I agree (and I didn't downvote). I simply think this should be clearer. | |
| Apr 15, 2013 at 9:13 | comment | added | Quentin | @dystroy — Yes, you have to use apply or call. That doesn't mean you can't use it. | |
| Apr 15, 2013 at 9:11 | comment | added | Denys Séguret |
Try "abc".forEach(function(v){console.log(v)}). You'd have to use apply or call.
|
|
| Apr 15, 2013 at 9:11 | history | answered | Quentin | CC BY-SA 3.0 |