Created
September 21, 2012 17:28
-
-
Save kevincennis/3762778 to your computer and use it in GitHub Desktop.
Block labels in JS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function isEven(val){ | |
evaluate: { // Block label, not an object literal | |
if ( val % 2 == 0 ) break evaluate; | |
return false; | |
} | |
return true; | |
} | |
isEven(4) // true | |
isEven(7) // false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment