Timeline for passing variables from function as argument
Current License: CC BY-SA 3.0
15 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Sep 15, 2016 at 18:49 | comment | added | user1106925 |
Strange. The .forEach shouldn't work on a NodeList unless NodeList.prototype has been extended with iterator methods.
|
|
| Sep 15, 2016 at 18:39 | comment | added | ardev |
@squint because querySelectorAll returns a NodeList, however it worked as written in this post. Just to be safe, I switched in [ ].forEach.call(listItems, function(){
|
|
| Sep 15, 2016 at 18:19 | comment | added | ardev | @bergi, thanks for pointing that out -- doesnt have anything to do with higher-order functions...scope or callback function wouldve been a better tag. | |
| Sep 15, 2016 at 18:13 | vote | accept | ardev | ||
| Sep 15, 2016 at 18:10 | answer | added | Amber Beriwal | timeline score: 0 | |
| Sep 15, 2016 at 17:45 | answer | added | Ma3x | timeline score: 1 | |
| Sep 15, 2016 at 17:21 | comment | added | user1106925 |
You're also going to discover that listItems doesn't have a .forEach() method, but that's a separate issue.
|
|
| Sep 15, 2016 at 17:20 | comment | added | Bergi |
@ardev You're supposed to put them outside of the supportLists function, next to the calls that use the variables
|
|
| Sep 15, 2016 at 17:19 | comment | added | Bergi | I have no idea what this had to do with higher-order functions. | |
| Sep 15, 2016 at 17:19 | comment | added | ardev | get the same error if I put them in the processLi function. besides, arent I using them in the invocation which is sitting inside the parent function, not the callback? | |
| Sep 15, 2016 at 17:19 | history | edited | Bergi | CC BY-SA 3.0 |
edited tags; edited title
|
| Sep 15, 2016 at 17:17 | comment | added | GCSDC | Adding to @squint answer, you could declare the arrays on the same scope on which the function will be called and pass them as arguments for the function, or also pass the name of the links array to be used as an input parameter for the function and have a logic inside it to select and use the right array. | |
| Sep 15, 2016 at 17:14 | history | edited | Joseph | CC BY-SA 3.0 |
deleted 243 characters in body
|
| Sep 15, 2016 at 17:13 | comment | added | user1106925 |
You're trying to use those links variables outside the function where they're declared.
|
|
| Sep 15, 2016 at 17:12 | history | asked | ardev | CC BY-SA 3.0 |