Web Dev Roadmap for Beginners (Free!): https://bit.ly/DaveGrayWebDevRoadmap
Learn the difference between a Shallow Copy and a Deep Copy in this Advanced Javascript Tutorial. We cover shallow copy vs deep copy, mutable vs immutable and passing values vs references. Pure functions need you to know this foundational knowledge.
Subscribe https://bit.ly/3nGHmNn
JavaScript for Beginners: Full Course (8 hours): https://youtu.be/EfAl9bwzVZk
Javascript Recursion Tutorial: https://youtu.be/Q0alTGQ-lXk
Shallow Copy and Deep Copy | Advanced Javascript Tutorial
(00:00) Intro
(0:24) Javascript data types review
(1:03) passing values vs passing references
(3:05) mutable vs immutable data
(5:52) an impure function
(8:20) how to make a shallow copy
(14:17) how to shallow freeze an object
(16:04) how to make a deep copy
(21:43) a pure function
(23:45) Review of concepts
References:
MDN data types and data structures: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures
"Four Ways to Immutability in Javascript": https://dev.to/glebec/four-ways-to-immutability-in-javascript-3b3l
"How to Deep Copy Objects and Arrays in Javascript": https://javascript.plainenglish.io/how-to-deep-copy-objects-and-arrays-in-javascript-7c911359b089
"What is the most efficient way to deep clone an object in JavaScript?" https://stackoverflow.com/questions/122102/what-is-the-most-efficient-way-to-deep-clone-an-object-in-javascript
Follow Me:
Twitter: https://twitter.com/yesdavidgray
LinkedIn: https://www.linkedin.com/in/davidagray/
Blog: https://yesdavidgray.com
Reddit: https://www.reddit.com/user/DaveOnEleven
Was this tutorial about Shallow Copy and Deep Copy in Javascript helpful? If so, please share. Let me know your thoughts in the comments.
#shallow #deep #copy