JavaScript+Primer
JavaScript+Primer
Variables
They can be assigned with some initial values using the equals operators.
var myFirstVariable = 0;
Types
You can instantiate an object using the new operator like this:
var aDate = new Date();
Comments
Comments can use the double slash single line or the C-style multiline
comment format:
// this is a single line comment
/*
This is a multi-line comment
*/
Basic Operators
Conditionals
You can use the comparison operators, < (less than) > (greater than) <=
(less than or equal) >= (greater than or equal) == (equals) != (not equals) in if
statements as follows:
var a = 1;
var b = null;
if (a > 0) {
b = “a is greater than zero”;
} else {
b = “a is zero or less”;
}
Loops
Functions
Callbacks
Exception Handling