JavaScript: Primitive Value

By Xah Lee. Date: . Last updated: .

Primitive Value

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

[see Value Types]

The following values are β€œPrimitive Values”.

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.

You can create number, string, boolean, objects yourself. (but is not useful.) For example:

new String(arg) [see String Constructor]

new Number(arg) [see Number Constructor]

new Boolean(arg) [see Boolean Constructor]

Convert Primitive Value to Object

Use Object(val) [see Object Constructor]

JavaScript Value Types

βˆ‘ JS in Depth
XAH Β BUY NOW

JS in Depth

JS Obj Ref

DOM


JS in Depth

Basic Syntax

Value Types

Variable

String

Function

Property

Object and Inheritance

Array

Constructor/Class

Iterable 🌟

Misc