To facilitate operation of the base type value, ECMAScript provides 3 special reference types:Boolean, number, and String. These types are similar to other reference types, but also have special behaviors corresponding to their respective base types. in fact, every time a primitive type value is read, the background creates an object of the corresponding basic wrapper type, which can invoke some methods to manipulate the data.
Classic Example 1:
A string object is a primitive type, but it is also a special reference type (Basic wrapper type: an internally created object that can invoke its own internal special behavior)
1 var str = "ABCD"; 2 Str.length = 2; 3 // the output is ABCD
Above str.length = 2; the actual execution is new string ("ABCD"), then new string ("ABCD"). Length = 2, and then delete destroys the object, regardless of the previous object, so when you access Str later, or ABCD;
JavaScript Basic Packaging Class Introduction