Programming Journal #1

in #javascript7 years ago

Intro to Rixi's Programming Journal

Hey guys, I'll be beginning to post new and interesting facets of Javascript (and soon comparisons of Javascript with Java) learnt throughout the week.

Javascript Labels

Image of Javscript

Scenario: You are in a nested if statement and want to break out of a loop (i.e. a for or while loop). A breakwill only exit out of the current block it's in. So if you're trying to break out once you hit a condition, you will need consecutive breaks to eventually, exit out of your loop.

This can get messy, and pollute your code.

Comes in the label.

currentWhileLoop: while( fooBar === true) {

Using this line below:
break currentWhileLoop;

will break you out of the loop, regardless where you place this statement.

Coin Marketplace

STEEM 0.21
TRX 0.25
JST 0.038
BTC 95472.56
ETH 3354.78
USDT 1.00
SBD 3.13