Basic packaging types

Time:2021-2-23

Basic wrapper type is to wrap simple data type into complex data type.

var str = ‘andy’;

console.log(str.length);

Only objects and complex data types have attributes and methods. Why is there a length attribute?

The process is as follows

Var temp = new string (‘andy ‘); / / wrapped as complex data type

STR = temp; / / give the value of the temporary variable to str

Temp = null; / / the temporary variable will be destroyed automatically