Skip to content

Instantly share code, notes, and snippets.

@dginev
Created February 7, 2017 15:16
Show Gist options
  • Save dginev/bf96fad96d68faca242d25f035fdde18 to your computer and use it in GitHub Desktop.
Save dginev/bf96fad96d68faca242d25f035fdde18 to your computer and use it in GitHub Desktop.
You can't use break inside of .forEach?!
try {
someArray.forEach((content, index) => {
// do stuff with content
if (breaking_condition) {
throw "Table"; // breaks forEach (╯°□°)╯︵ ┻━┻)
}
})
} catch (e) {
// short-circuited forEach ┬──┬◡ノ(°-°ノ)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment