JS: Primitive Value

By Xah Lee. Date: . Last updated: .

Primitive Value

A primitive value is a value whose type is a primitive type.

The following values are “Primitive Values”.

[see JS: Value Types]

Primitive Value Object Wrapper

Most primitive type have corresponding object of object type.

The object is used as primitive value wrapper. This allows you to call methods on them, such as "abc".length or (34).toString().

You can create number, string, boolean, objects yourself. (but is not useful to do.)

For example:

new String(arg) [see JS: String Constructor]

new Number(arg) [see JS: Number Constructor]

new Boolean(arg) [see JS: Boolean Constructor]

Convert Primitive Value to Object

Object(prim) → converts a primitive value to its corresponding object.

[see JS: Object Constructor]

JS Types

  1. Value Types
  2. Primitive Value
  3. Object Type
  4. “typeof” Operator
  5. Find Object's Type
  6. Object.prototype.isPrototypeOf
  7. Property Key “constructor”
  8. “instanceof” Operator
Liket it? I spend 2 years writing this tutorial. Help me spread it. Tell your friends. Or, Put $5 at patreon.

Or, Buy JavaScript in Depth

If you have a question, put $5 at patreon and message me.

Web Dev Tutorials

  1. HTML
  2. Visual CSS
  3. JS in Depth
  4. JS Object Reference
  5. DOM Scripting
  6. SVG
  7. Blog