Console Learner — An interactive JavaScript course.


2.4 Statements

>>>
var a = 1;
var b = a + 1;

  
A ; character is used to separate statements. Several statements can be placed on a single line, although it is commonly avoided.
>>>
{
    var a = 1;
    a += 2;
}

  
The { and } characters are (also) used to group several statements. This is sometimes called a block.
>>>
a = 1, b = a + 1
2
The , operator in expressions is similar to the ; statement separator. It evaluates both expressions, but will only return the second one. Compare with the boolean operators:
>>>

The console allows you to interact with the course material and examples. Use the following keys:

A special logging function is also available:


Need more magic? Check out the other developer tools on this site.