- Numbers, such as 42 or 3.14159
- Logical (Boolean) values, either
- Strings, such as "Howdy!"
null, a special keyword denoting a null value;
nullis not the same as
NULL, or any other variant
undefined, a top-level property whose value is undefined;
undefinedis also a primitive value.
Date object and its methods to handle dates.
Objects and functions are the other fundamental elements in the language. You can think of objects as named containers for values, and functions as procedures that your application can perform.
Data Type Conversion
var answer = 42;
And later, you could assign the same variable a string value, for example:
answer = "Thanks for all the fish...";
x = "The answer is " + 42 // returns "The answer is 42" y = 42 + " is the answer" // returns "42 is the answer"
"37" - 7 // returns 30 "37" + 7 // returns "377"