Skip to content

Commit

Permalink
Add documentation that doing something stupid will have a stupid resu…
Browse files Browse the repository at this point in the history
…lt, fix #2553
  • Loading branch information
gfwilliams committed Sep 23, 2024
1 parent 0f3e94f commit 2219501
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/jswrap_array.c
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,9 @@ JsVar *jswrap_array_every(JsVar *parent, JsVar *funcVar, JsVar *thisVar) {
Execute `previousValue=initialValue` and then `previousValue =
callback(previousValue, currentValue, index, array)` for each element in the
array, and finally return previousValue.
**Note:** If you add elements to the array you're iterating over while you're iterating,
you will iterate over those events too, creating an endless loop. For example: `a=[1,2,3];a.reduce(() => a.push(0), 0);`
*/
JsVar *jswrap_array_reduce(JsVar *parent, JsVar *funcVar, JsVar *initialValue) {
if (!jsvIsIterable(parent)) {
Expand Down

0 comments on commit 2219501

Please sign in to comment.