Now that you have the basics of JavaScript and working with JavaScript in the web down, we wanted to revisit some fundamental concepts and give you a deeper understanding of how to use them effectively in your programs.
These exercises will take a closer look at objects and arrays in JavaScript.
- Using Visual Studio Code, open the folder
flexpath-revisit-objects-and-arrays-exercises
wherever you saved it on your device. - Then open the
flexpath-revisit-objects-and-arrays-exercises/exercises
folder. Inside are a collection of folders for each exercise. Exercise instructions are provided to you in .txt files in these folders. - To test your code, you will open up your terminal, and navigate to the specific
exercise_[number]
folder inside of the largerexercises/
folder where you are working in, using the change directory commandcd
. - You will then run the command
node [filename].js
to run whichever file in the folder you are working with, replacing[filename]
in the command with the file's actual name.
Exercise solutions are in the /solution
folder
Note:
For the first few exercises in this repository, we have included example JS code you can use to test your solutions.
But, after the first few exercises we don't provide it anymore.
As a Software Developer, you will have to both solve a problem given to you and come up with code on your own to test that your solution to that problem actually works.
This is an important skill to build, and it is vital to being able to do this job.
Therefore, we want you to start getting comfortable writing JavaScript code to test that your solutions work as intended.
-
Objects in JavaScript:
- Understanding what objects are and how they serve as containers for key-value pairs.
- Creating objects using object literals and the
new
keyword. - Object properties and methods, including how to add, update, and delete properties.
- Reference types vs. primitive types and the implications for memory management.
- Using
Object.create
to define custom prototypes. - Understanding how JavaScript uses prototypes and the prototype chain.
-
Array Manipulation:
- Creating arrays using literals and the
Array
constructor. - Adding and removing elements using
push
,pop
,shift
, andunshift
. - Using
splice
andslice
for modifying and extracting array elements. - Combining arrays with
concat
and the spread operator. - Cloning arrays and the concept of shallow vs. deep copying.
- Creating arrays using literals and the
-
Iteration Methods:
- Using
forEach
,map
,filter
, andreduce
for efficient array iteration and manipulation. - Understanding the power and use cases for these methods compared to traditional
for
loops.
- Using
-
Prototypes and Inheritance:
- How objects inherit properties and methods from their prototypes.
- The difference between object-oriented principles and JavaScript’s prototype-based inheritance.
- The use of
Object.defineProperty
and property descriptors to control object properties.
-
Advanced Topics:
- Memory management with stack and heap.
- Concepts like object freezing with
Object.freeze
and sealing withObject.seal
. - Enumerability, property attributes, and protecting object properties.