In JavaScript Primitives are immutable, which means that the value is passed instead of reference.
For Objects the reference is passed instead of value. Example as below,
//Primitives are immutable
var a = 10;
var b = a;
console.log("a: "+a);
console.log("b: "+b);
a =20;
console.log("a: "+a);
console.log("b: "+b);
//Mutable
var c = {name: "Zack"};
var d = c;
console.log("c: "+c.name);
console.log("d: "+d.name);
d.name = "Arnold";
console.log("c: "+c.name);
console.log("d: "+d.name);
Ensure whether you are passing value or reference during development. This is one of the basic concepts in JavaScript.
Hello, an amazing Information dude. Thanks for sharing this nice information with us. Rapid Covid Test
ReplyDeleteWhat a nice Blog, thanks for sharing such important info about Industrial gases supplier .Keep learning Keep loving.
ReplyDeleteMagnificent work.
ReplyDeleteThank you for sharing such a detailed information.
we at Glocalview infotech Provides All kind of web development & Mobile app development services