Skip to content

Instantly share code, notes, and snippets.

@x1unix
Forked from berzniz/jshipster_and_and.js
Last active August 29, 2015 14:26
Show Gist options
  • Select an option

  • Save x1unix/1b3ed5e2754ccf744c78 to your computer and use it in GitHub Desktop.

Select an option

Save x1unix/1b3ed5e2754ccf744c78 to your computer and use it in GitHub Desktop.
Some small javascript hacks for hipsters
// 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
var x = 1;
debugger; // Code execution stops here, happy debugging
x++;
var x = Math.random(2);
if (x > 0.5) {
debugger; // Conditional breakpoint
}
x--;
var a = meaningOfLife || 42;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment