javascript interactive

JavaScript Interactive — a console crash course

1.2 Object Types

Warning: Your browser may be outdated or unsupported.

The JavaScript console is known to display some of the examples incorrectly in Internet Explorer 8 or older.

The primitive object type is the basis for a number of built-in object types:

  • Object – Container for a sequence of named values (properties).
  • Array – Container for a sequence of ordered values.
  • Boolean – Wraps a primitive boolean value. Seldom used.
  • Number – Wraps a primitive number value. Seldom used.
  • String – Wraps a primitive string value. Seldom used.
  • Function – Contains executable code for a function (or procedure).
  • RegExp – Contains a compiled regular expression.
  • Date – Contains a timestamp (date & time) value.
{ a: 'value', b: 123, 'c': null }
This object literal syntax is also known as JSON and is commonly used for data transfer.
[1, 2, 'c']
[1, 2, \"c\"]
Array literals are also part of JSON.
( function() {} )
function () {
Functions are explained in detail in a later chapter. For now it is enough to note that functions are first-class citizens, i.e. can be handled as any other value.
A regular expression literal is converted to a RegExp object at run-time, not parse-time. This means that some errors won't be detected until the code is executed.

Index 1 2 3 4 5 6 7