Data Type

The basic data types of JavaScript are letters, numbers, and boolean.
When declaring a variable, prefix the variable name with var.

var city = "New York";//or 'New York'
var result = 1200 / 1000;
var onGlass = true;
alert('city: ' + city);
alert('result: ' + result);
alert('onGlass: ' + onGlass);

Local variables and global variables

A local variable is a variable declared within a function and can only be used within a function.
A global variable is declared outside of a function and can be used by any function.
A variable declared without var is a global variable, regardless of whether the variable is inside or outside the function.
However, it is a good practice to always add var when declaring variables.

Constant

To declare a constant, precede the constant name with const.
Constant names consist of uppercase letters and _.
There are global constants and local constants like variables.

const PI = 3.14;
alert('PI: ' + PI);

Comment

// is a one-line comment.
/* ~ */ is a multiline comment.

Identifier

Identifiers can be made by combining letters, numbers, _, and $.
JavaScript identifies the case of identifiers.
Keywords can not be used as identifiers.

undefined

undefined means 'no value assigned' when a value is referenced while the variable is declared and uninitialized.

var i;
alert('i: ' + i);

It is false if the condition is 0, "", NaN, undefined.

var i;
if (i) {
	alert('i: ' + "true");
} else {
	alert('i: ' + "false");
}