🔧 What is Value Types and Reference Types in JavaScript
Nachrichtenbereich: 🔧 Programmierung
🔗 Quelle: dev.to
Two fundamental categories that every developer should understand are value types and reference types. Value type is basically it will not changeable after something is assigned to variable and reference type is what we can change after declaration.
In JavaScript objects are reference type and all other data types are value types. It is important to know the difference between this to datatypes which will help you avoid common pitfalls and write more efficient code.
Value type example
let a = 10;
let b = a; // b is now 10
b = 20; // changing b does not affect a
console.log(a); // 10
Reference type example
let obj = { name: 'John' };
obj.name = 'Doe'; // the original object is modified
console.log(obj.name); // 'Doe'
Learn more...
🔧 Value type vs Reference type in JavaScript
📈 23.69 Punkte
🔧 Programmierung
🔧 Value Type and Reference Type
📈 19.66 Punkte
🔧 Programmierung
🔧 Value Type and Reference Type 2
📈 19.66 Punkte
🔧 Programmierung
🔧 Value Type and Reference Type
📈 19.66 Punkte
🔧 Programmierung
🔧 Value Type and Reference Type
📈 19.66 Punkte
🔧 Programmierung
🔧 Reference Type and Value Type in Swift
📈 19.66 Punkte
🔧 Programmierung
🔧 Value type va Reference type
📈 18.49 Punkte
🔧 Programmierung
🔧 Value Type va Reference Type
📈 18.49 Punkte
🔧 Programmierung