Skip to content

Instantly share code, notes, and snippets.

@ebonneville
ebonneville / helloworld.js
Created April 24, 2012 15:05
Hello World
alert("Hello, world!");
if (someVar > otherVar) {
booleanVar = true;
} else {
booleanVar = false;
}
someVar > otherVar ? booleanVar = true : booleanVar = false;
var mySecondVar = (myFirstVar) ? myFirstVar : myThirdVar;
if (someVar > 10) {
otherVar = true;
}
someVar > 10 && (otherVar = true);
parseInt("10");
>> 10
parseInt("010");
>> 8
parseInt("010", 10);
>> 10
parseInt("10.9", 10);
"10.5"*1;
>> 10.5
"010.5"*1;
>> 10.5
"s10.5"*1;
>> NaN
"10.5s"*1;
parseFloat("10.5");
>> 10.5
parseFloat("s10.5");
>> NaN
parseFloat("10.5s");
>> 10.5
parseFloat("10.5 5.10");
if(someVar == undefined) {
// this code should execute if someVar is undefined, but it doesn't
}