JavaScript contains a small set of data types. It has the three primitive types boolean, number, and string and the special values null and undefined. Everything else is variations on the object type.
Boolean has two values: true and false.
Number is 64-bit floating point, similar to Java's double and Double. There is no integer type. Division[e23] between two integers may produce a fractional[e24] result. Number also includes the special values NaN (not a number) and Infinity.
String is a sequence[e25] of zero or more Unicode characters. There is no separate character type. A character is represented as a string of length 1. Literal strings are quoted using the ' or" characters. The quote[e26] characters can be used interchangeably[e27] , but they have to match[e28] .
'This is a string.'
"Isn't this a string? Yes!"
'A' // The character A
"" // An empty string
Escapement[e29] is done with the \ character, like in Java. Strings are immutable[e30] . Strings have a length member which is used to determine the number of characters in the string.
var s = "Hello World!";
s.length == 12
It is possible to add methods to the simple types. So, for example, you can add an int() method to all numbers, so that Math.PI.int() produces 3.
An implementation[e31] may provide other types, such as Dates and Regular Expressions, but these are really just objects. Everything else is just objects.