Wrapper object: The base type has its own corresponding wrapper object: String number Boolean.
For example
var str = ' Hello ';
Str.charat (0); Here is the method of Sting type wrapper object string. When this sentence is executed, the base type finds the corresponding wrapper object type, and then wraps the object to give the base type all the properties and methods, and then the wrapper object disappears. Look at the following question .
var str = ' Hello ';
Str.number = 10;
alert (Str.number); Undefined
The result here is undefined. When executing the first sentence, STR is a basic type, when executing the second sentence, STR is an object of the wrapper object, and adds a property number to it, and then disappears.
When executing to the third sentence, STR is the object of another wrapper object, without the number attribute, so the result is undefined.
The right approach should be
var str = ' Hello ';
String.prototype.number = 10;
alert (Str.number);
JS Wrapper Object