I recently had a coding interview that involved evaluating one schema against another. The details of it aren't that important, but one thing that ...
For further actions, you may consider blocking this person and/or reporting abuse
You can use .every() instead and return false whenever you want to
break
. Return true to keep goingInteresting! Thank you for your insight. I haven't used
every
much. Very handy!.some()
is probably even better in most cases. Just return true whenever you need tobreak
. No need to return anything when you want to keep going :)Sweet! May have to do a deep dive article into all the various loop types.
This is so helpful
Thanks! Any other topics you'd like me to tackle?
Awesome article! Minor nitpick though:
Array.prototype.forEach()
and its siblingsmap
,filter
,reduce
,reduceRight
,some
, andevery
were all actually introduced back in 2009 with ES5!I bring this up not for know-it-all points, but because it's important for browser compatibility. Most of these methods are available in browser versions going back 10+ years, which is super important and helpful if, like me, you work in an environment where you still need to maintain support for those browsers π
Thank you for the correction! I'm the only one who edits these things, so I appreciate any and all feedback. I'll update it to reflect accurate info!
I feel you though, I have to support old browser's too
I always remember that forEach() loop can't be break but i never know why, until now haha. Great article, thanks!
Thanks!
But why they keep all these different versions of doing the same things? That is, forEach(), every() and some().
I mean, you can if you really want: just throw sg from the callback.