Objects and Arrays in JS are fundamental in data structure and organization. As such, accessing them is equally important. Luckily with modern JS, there are better ways of accessing them through deconstruction.
Deconstruction is the concept of breaking down an object or array to access a specific value more easily. To better explain, let’s look at some code.
const testObject = {a: 1, b: 2, c: 3};
const testArray = [1,2,3,4];
// Deconstricting Object
const { a, b, c } = testObject;
a; // 1
b; // 2
c; // 3
// Deconstructing Array
const [first, second, third, forth] = testArray;
const {1: five} = testArray;
five; // 2
first; // 1
second; // 2
third; // 3
forth; // 4