-
-
Save x1unix/1b3ed5e2754ccf744c78 to your computer and use it in GitHub Desktop.
Some small javascript hacks for hipsters
This file contains hidden or 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
| // Boring | |
| if (isThisAwesome) { | |
| alert('yes'); // it's not | |
| } | |
| // Awesome | |
| isThisAwesome && alert('yes'); | |
| // Also cool for guarding your code | |
| var aCoolFunction = undefined; | |
| aCoolFunction && aCoolFunction(); // won't run nor crash |
This file contains hidden or 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
| var x = 1; | |
| debugger; // Code execution stops here, happy debugging | |
| x++; | |
| var x = Math.random(2); | |
| if (x > 0.5) { | |
| debugger; // Conditional breakpoint | |
| } | |
| x--; |
This file contains hidden or 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
| var a = meaningOfLife || 42; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment