Skip to content

Tag: foreach

Making my own ForEach() javascript – element is not defined

I am making my own implementation of forEach in javascript, with the sole purpose of understanding the language better. To be more specific the temporary goal is to understand callbacks better. This is how far I got until I got stuck. I get the following error when running in node: I suspect it is because whe…

Reactjs map works but forEach doesn’t

I’m struggling to understand the difference between forEach and map. In the following render function if the ‘forEach’ is replaced with ‘map’ it works. I don’t understand why it doesn’t work with the ‘forEach’. Both {item.id} and {item.text} are present wi…

“continue” in cursor.forEach()

I’m building an app using meteor.js and MongoDB and I have a question about cursor.forEach(). I want to check some conditions in the beginning of each forEach iteration and then skip the element if I don’t have to do the operation on it so I can save some time. Here is my code: I know I could turn…