From the course: JavaScript Patterns: Modern Solutions to Common Challenges
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
Solution: JSON.stringify() and JSON.parse() - JavaScript Tutorial
From the course: JavaScript Patterns: Modern Solutions to Common Challenges
Solution: JSON.stringify() and JSON.parse()
- [Instructor] In this video, we'll address how to make actual copies of objects in JavaScript. There is, as far as I know, anyway, no completely simple answer to this question, but there are good ones. We just need to consider what's in our objects before we choose one. So I'd recommend loading up the index.html file for this example in your browser before we start. Back here in my editor, I have the JavaScript file that goes with the example, and I've made my kitty object a little more complex here. I have the same properties as I did before, basic strings and a number, but I also have a key called offspring, which contains an array. This is all the kittens that this kitty might've had. An object for their best friend, which let's say here is a parakeet named crackers, and then a function called meow, which will return a string where the kitty says meow, and we get their own name. So we have a few different types…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
(Locked)
Pain point: Copied objects are not actually copies2m 32s
-
(Locked)
Solution: JSON.stringify() and JSON.parse()7m 55s
-
(Locked)
Pain point: The value of "this" can be hard to follow3m 52s
-
(Locked)
Solution: Fix "this" using bind()5m 38s
-
(Locked)
ES6+ solution: Arrow functions3m 38s
-
(Locked)
Solution: Creating a unique robot army2m 53s
-
(Locked)
-
-