JavaScript has five primitive data types,
- Undefined
- null – a special keyword denoting a null value.
- Boolean – a logical entity that consists of either a true or false value.
- Number – a set of numerical digits that represent a number.
- String – a set of zero or more characters.
Variables
You can use variables as symbolic names for values in application. The names of variables, is called identifiers. Variables can be declared with keyword “var”.
Variable scope
When you declare variables outside of function , its called global variable. When you declare within a function, its called local variable. JavaScript does not have block statement scope.
Hoisting
You can refer to variable declared later without getting exception. This concept is called “Hoisting”, variables in JavaScript are in a sense “hoisted” or lifted to the top of the function.
Constants
You can create read-only, named constant with “const” keyword. A constant cannot change value through assignment.
Literals
These are fixed values, not variables, that you literally provide in you script.
Array Literals
var
coffees = [
"French Roast"
,
"Colombian"
,
"Kona"];
Boolean Literals
The boolean type has two literal values “true”, “false”.
Object Literals
An object literal is a list of zero or more pairs of property names and associated values of an object, enclosed in curly braces.
String literals
A string literal is zero or more characters enclosed in double or single quotation marks.
References
https://developer.mozilla.org/en-US/docs/JavaScript/Guide/Values,_variables,_and_literals