js basics - basic wrapper types

 

var t = 13;

t.toString(); //t is a simple numeric type and now has a method toString object type method

       // Numeric types have corresponding wrapper types

var t1 =new Number(333) // t1 is wrapped as a reference type and is an object instance of Number

 

For boolean type, numeric type, and string type js provides corresponding packaging types as three types of variables

When doing a read operation, the js engine will automatically create a temporary wrapper object to help him access the methods of the wrapper type

Destroy the wrapper object immediately after use

var t = 19; t.age = 19;//Create a temporary object and destroy the console.log(t.age) //undefined

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325163628&siteId=291194637