Mutability vs Immutability in JavaScript

preview_player
Показать описание
The concept of mutability and immutability in JavaScript is essential to understand to avoid errors. Mutable can be changed or added to where immutable means something that cannot be changed or added. Primitive values in JavaScript cannot have anything added upon to them, they can only be re-assigned, and hence all primitive values in JavaScript are immutable. Let’s dive deeper into the idea of mutability vs. immutability in JavaScript.

🔥🔥 FREE JavaScript Cheat Sheet 🔥🔥

👾 Subscribe For More Tutorials 👾

📓 Full Example With Code 📓

📖 Video Chapters
00:00 Video Intro
00:32 Primitive types vs Reference Types
01:19 Six primitive types in JavaScript
01:31 Three reference types in JavaScript
01:39 How primitive types and reference types are different
03:52 Mutability vs Immutability in JavaScript
06:30 Introduction to spread operator

🌟 Exciting And Insightful Content About JavaScript 🌟
Рекомендации по теме
Комментарии
Автор

I've heard a lot about concepts like "primitive & reference" types and "mutability & immutability" in JS but never understand them thoroughly until now. Your way of explanation is simple and understandable. Thank you for sharing!

mahmoudhassen
Автор

What an under-watched channel, I didn't expect much because of the low view count (470?!), but this is of the same quality as much larger channels, I think you will blow up soon just keep making videos of this quality.

bookdream
Автор

The fluffy intro that starts at 0:23 is exactly what is meant by "further ado". Instead of diving deeper into it right away, you saddled us with *further ado* -- right after making a verbal commitment that there would be no more of that.

edwardkasimir
Автор

The author showed the wrong example of string's immutability. It only shows that STRING are PRIMITIVE type, but it is not about immutability.
Example of string immutability:

const str = "Hello"
str[0] = "B"
console.log(str); // Hello

dmytronice
Автор

Cleared my concept in 7mins instead of reading 100's of lines...thanks

seeyou
Автор

I am amazed at the beauty and clarity of the explanation. Thank you very much, keep going

ibrahim_youssef_.
Автор

This is a great video and really solidified my understanding of this concept. Please keep producing these videos they are excellent. Thanks so much!

pgallovich
Автор

Great Video! Thank you! Please continue the work!

bojankustura
Автор

Thanks, my friend. I am learning functional programming and this immutability concept has been very hard to get used to. Your video helped me a lot!

danieljazz
Автор

wow this is so simple to follow! thanks

MrChubib
Автор

very simple style of teaching, I like it a lot

PaintingAndPolitics
Автор

This is a good beginner's introduction. Well done video!
More info: cloning / copying objects and arrays really has no shortcut in JS. Properties that are objects will still be referenced, not copied. And since objects can have circular references, even writing an algorithm to handle it is non-trivial.
(Then there's the really weird stuff like proxies, non-enumerated keys, copying the prototype chain, etc.)

jonmichaelgalindo
Автор

Thanks for giving such a clear explanation !! This video is really helpful for developers in identifying errors caused by mutability.

priyadharshiniv
Автор

Very Very Well Explained
Thank you Soo much Dear

ScoreMatch_
Автор

Wow thanks for the video, it helped me so much! :D

uncristobalito
Автор

Such a great explanation bro! thanks a bunch.

migueljurado
Автор

You forgot to mention one more primitive type in js there are 7 primitive types not 6

wisdomeispower
Автор

Making a change to either Variable representing the person Object doesn't change 'person1' and 'person2' at the same time - It changes ONCE what both Variables are referencing. This is a HYPER important distinction. It's not going through 100, 000 objects and changing their values 100, 000 times it's just changing the value 1 time that 100, 000 objects are pointing to.
ALSO
It would be a good time to explain how to CLONE an object so that you CAN treat them as two separate entities if you so desire.

AND
Objects, Arrays and Functions...Really? Arrays and Functions ARE Objects (in JavaScript); thus strictly speaking there is really ONLY ONE Reference type, Objects with Arrays and Functions being a subset of Objects (as are Dates, Math Objects and Regular Expressions too - but these are tied to the compiler as a special type of 'constant' thus they can't be corrupted).

LrCloud
Автор

i rarly comment but you are great sir keep it on

yousseftawfik
Автор

You do a big mistake. Array and Function are Object. They are a subtype of Object

failure