But what exactly is this Flying Ships and Object Cloning short course? I would describe it less as a course and more of a journey - a journey of discovery. From here on, you will receive a total of 6 more emails, sent 1 day apart.
Each email will tackle a new concept that will help us eventually achieve two things:
What is the point of imagining fantasy landscapes if they don't help us as developers? We will first be applying our new way of thinking to a code snippet provided below, which expose so many important JS topics. I will also provide a few exercises and questions at the end of this course for extra practise!
Cloning, as the name suggests, is taking an object or an array and making an exact replica of it. It's important to be able to do this, so you don't waste time manually writing an object every time. Instead you take an existing one, make a copy of it and get all the same keys and values.
Soon you will know exactly what is meant by this, and if you already know, you will have a better understanding of the complex processing that needs to happen to achieve a deep clone. This is the MDN Doc's definition:
"A deep copy of an object is a copy whose properties do not share the same references (point to the same underlying values) as those of the source object from which the copy was made. As a result, when you change either the source or the copy, you can be assured you're not causing the other object to change too; that is, you won't unintentionally be causing changes to the source or copy that you don't expect."
Let's take a look at an example. The goal of this course will be to visually explore and breakdown this example.
In the code below, the task is to update the blog post of a user in our application. Unfortunately, he did not capitalise his post title. We must fix it for him.
We must not mutate the original app data in any way! Why? It might cause a bug in our program that is difficult to track down. So the task is to create a completely new version of our app data, instead of updating the old one. Take a look:
If the code looks ridiculously confusing to you, well, it should! There's a whole lot of stuff going on here, including:
In order to truly understand and appreciate the code above, we are going to learn about each topic. The best part? The Great Sync will give us all the tools we need to look at the problem from a different angle, and help us memorise the fundamental rules that govern all values in our programs.
Ready steady? Look out for my next email 😊