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
Like it? Help me by telling 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