Sorry, your browser is not supported
To have the best experience using Skillshare, we recommend that you use one of these supported browsers.

Learn plain Javascript concepts by building a utility that clones deeply nested Javascript objects

Mike M., Learn and Share

Play Speed
  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x
9 Videos (31m)
    • Introduction

      2:04
    • Basic setup

      2:18
    • Implement 'isObject' helper function

      3:27
    • Implement 'isArray' helper function

      3:37
    • Clone non-object data and arrays

      4:06
    • Clone an object

      3:45
    • Clone a nested object

      3:58
    • Testing your code with objects

      4:20
    • Testing your code with an array of objects

      3:31

About This Class

5f13116c

In this tutorial you will build a library that will help you clone deeply nested Javascript objects and arrays. In the process, you will learn about several Javascript concepts that you will find useful when working with objects and arrays.

Copying of Javascript objects is done by reference. That means, your copied object shares the same memory address as your original object.

So, if you decide to change the value of a property on the copied object, you will end up modifying the value of the same property on the original object. 

This can be dangerous in many cases, where you unintentionally change the state of an object from somewhere else, which may result in causing unexpected behaviors in your application.

In the process of building this library you will learn about:

  •  Javascript objects and properties,
  •  why copying objects by reference can be dangerous,
  •  what is meant by cloning an object,
  •  creating helper functions that will do type checking on data,
  •  creating a function that will implement cloning for three different cases (data types) where the data is not an object or is null, where the data is an array holding elements of different data types and where the data is an object (and deeply nested object)

4

Students

--

Projects

0

Reviews (0)

Mike M.

Learn and Share