Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
The JavaScript values 5, 'foo', true,
and false, as well as null and undefined, are considered primitive because they
are irreducible. That is, a number is a number, a
string is a string, a boolean is either true or false, and null and undefined are just that, null and undefined. These values are inherently simple,
and do not represent values that can be made up of other values.
Examine the code below and ask yourself if the string, number,
boolean, null, and undefined values could be more complex. Contrast
this to what you know of an Object() instance or Array() instance or really any complex
object.
<!DOCTYPE html><html lang="en"><body><script> var myString = 'string' var myNumber = 10; var myBoolean = false; // could be true or false, but that is it var myNull = null; var myUndefined = undefined; console.log(myString, myNumber, myBoolean, myNull, myUndefined); /* Consider that a complex object like array or object can be made up of multiple primitive values, and thus becomes a complex set of multiple values. */ var myObject = { myString: 'string', myNumber: 10, myBoolean: false, myNull: null, myUndefined: undefined }; console.log(myObject); var myArray = ['string', 10, false, null, undefined]; console.log(myArray); </script></body></html>