JS: Primitive Value Object Wrapper

By Xah Lee. Date: . Last updated: .

What's Primitive Value?

[see JS: Primitive Value]

String or number are not objects, why do they have methods?

When using a method of a number (or string), such as "abc".length , the primitive value is automatically converted to object temporarily.

You can create number or string objects yourself. (but they are rarely needed.)

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

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

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

[see JS: Data Types]

Liket it? Put $1 at patreon.

Or, Buy JavaScript in Depth