JavaScript: Primitive Value Object Wrapper

By Xah Lee. Date: . Last updated: .

What's Primitive Value?

〔►see JavaScript: 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 JavaScript: String Constructor

new Number(arg) 〔►see JavaScript: Number Constructor

new Boolean(arg) 〔►see JavaScript: Boolean Constructor

〔►see JavaScript: Data Types

Like what you read? Buy JavaScript in Depth
or, buy a new keyboard, see Keyboard Reviews.