Skip to main content

Primitive Vs Reference Data Type

 // CLASS TOPICS : Primitive vs reference DATA TYPES   
   
   
 // PRIMITIVE TYPE  
 // x = 10;  
 // y = x;  
 // x = 20;  
 // console.log(x,y);  
 // here x and y both are same but locating different positions in memory and saved at diff places  
   
   
 // REFERENCE TYPE  
 // x = {name:"shagun",email:"abc@gmail.com"};  
 // y = x;  
 // x = {name:"abc"};  
 // console.log(x,y);  
 // both are pointing same location on memory but later on x is pointing a diff location  
   
   
 // REFERENCE TYPE  
 // x = {name:"shagun",email:"abc@gmail.com"};  
 // y = x;  
 // x.name = "testing name";  
 // console.log(x,y);  
 // both are pointing same location on memory. so if one is change other will also reflect the same change  
   
   
   
 // PRIMITIVE TYPES  
 // numbers , string , boolean , null , undefined  
 // REFERENCE TYPES  
 // object , array , functions are reference type  
   
   
   
   
   
   
   
   

Comments