Why JAVASCRIPT?
How to write and run Javascript
How to Add Javascript to Webpage
Representing data with values
Primitive Data Types
- Primitive Data Types
- Number Type
- String Type
- Boolean data type
- Undefined and null
- JavaScript Type Conversions
Operators
Expressions
Statements
- What are statements?
- Expression Statements
- Compound and Empty Statements
- Declaration Statements
- Conditional statements
- Loop statements
- Jump Statements
- Assignments
Arrays
Just as the comma operator combines multiple expressions into a single expression, a statement block combines multiple statements into a single compound statement. A statement block is simply a sequence of statements enclosed within curly braces. Thus, the following lines act as a single statement and can be used anywhere that JavaScript expects a single statement:
{
x = Math.PI;
cx = Math.cos(x);
console.log("cos(π) = " + cx);
}
A compound statement allows you to use multiple statements where JavaScript syntax expects a single statement. The empty statement is the opposite: it allows you to include no statements where one is expected. The empty statement looks like this:
;
The JavaScript interpreter takes no action when it executes an empty statement. The empty statement is occasionally useful when you want to create a loop that has an empty body.
// Initialize an array a
for(;;)