Deep copy type detection and

 

      //   deep copy 
        var user1 = {name: "Bob", age: 18, deMent: {bumen: " marketing", NO: "001" }} 
         
         var   user2 = the JSON.stringify (user1);
          var   USER3 = the JSON. the parse (user2); 

         user3.age = 40 ; 
         user3.deMent.no = "999" ; 


         the console.log (user1); // {name: "Bob", age: 18, deMent: {bumen: " Marketing" , NO: "001"}} 
         the console.log (USER3) // {name: "Bob", age: 40, deMent: {bumen: " marketing", NO: "999"}} 

         // step deep copy of the JSON.stringify (copied object); the objects into a string 
         // the JSON.parse (user2);It generates a new object based on the string 

         // type detection 
         / *
         Detecting basic data types used to detect typeof console.log (typeof basic types variable) 
         reference data types used to detect instanceof console.log (Function Function instanceof) 
         * / 

         // detector array 
         var ARR = [1,2,3,4, ,. 5 ]; 
         the console.log (Array.isArray (ARR)); // to true

 

Guess you like

Origin www.cnblogs.com/IwishIcould/p/11566237.html