Primitive data types are types that can be assigned a single literal value such as number, string or boolean value. Literals are fixed values.
Number consists of integer and floating point number and the special NAN (Not a Number value).
Integer (base 10) can be represented in decimal 0 to 9.
Octal (base 8) can be represented in decimal 0 to 7.
Hexadecimal (base 10) can be represented in decimal 0 to 9 and letter A to F.
Floating point are used to represent number that requires the use of a decimal point, or very large or very small numbers that must be written using exponential notation.
Example of floating point:- 12.4, -4.2.
Boolean cinsust of only two logical value true and false.
For example:- a==4
If the value of variable a is equal 4, if it is the result of this comparison is true. If a is not equal to 4, the result of the comparison is false.
String consists of string values that are enclsed in single or double quotes.
A string is a sequence of Zero or more charaacters that re enclosed within sing (‘) or double (“) quotes.
These characters can be letters, digital, punctuation character.
Example of string var a="two" alert (a); //This will alert "two"
Plus sing (+) used with sting var a="abc" alert(a+a); //This will alert "abcabc"
Null represents a single value, null that indicates “no values”.
Example of null var a=null alart(a); //This will open a dialog containing 'null'
Simple, if we declare a variable able by giving it a name but no value, that variable contains a values of undefined.
Example of undefined
alert (a) //This will open dialog containing “undefined”