There are six basic types of values in JavaScript:
numbers, strings, Booleans, objects, functions, and undefined values.
To create a value, you must merely invoke its name.
Values of the number type are, unsurprisingly, numeric values Special numbers There are three special values in JavaScript that are considered numbers but don’t behave like normal numbers. The first two are Infinity and -Infinity, which represent the positive and negative infinities. NaN stands for “not a number”, even though it is a value of the number type.
The next basic data type is the string. Strings are used to represent text. They are written by enclosing their content in quotes. "This is string" 'This is string'
Boolean values
JavaScript has a Boolean type, which has just two values: true and false.
Undefined values
There are two special values, written null and undefined, that are used to denote the absence of a meaningful value. They are themselves values, but they carry no information. All values in JavaScript have properties. Each property has a key (or name) and a value. You can think of properties like fields of a record. You use the dot (.)operator to read a property: value.propKey > var str = 'abc'; > str.length
Primitive Values Versus Objects
JavaScript makes a somewhat arbitrary distinction between values: The primitive values are booleans, numbers, strings, null, and undefined. All other values are objects.
Automatic type conversion
When an operator is applied to the wrong type of value, JavaScript will quietly convert that value to the type it wants,using a set of rules that often arent what you want or expect. This is called type coercion. The logical operators && and || handle values of different types in a peculiar way. They will convert the value on their left side to Boolean type in order to decide what to do, but depending on the operator and the result of that conversion, they return either the original left-hand value or the right-hand value.