arr.push(1, 2, 3);
arr.pop();
arr.shift();
arr.unshift(1, 2, 3);
Nested arrays and accessing/modifying
array data
Access nested array elements with
multiple indexes
Modify nested array elements by
assigning new values
Examples:
let arr = [[1, 2], [3, 4]];
console.log(arr[0][0]); // 1
arr[0][0] = 5;
console.log(arr); // [[5, 2], [3,
4]]
Destructuring assignment with arrays
Assign variables from array elements
with a destructuring syntax
Examples:
let arr = [1, 2, 3];
let [x, y, z] = arr;
console.log(x); // 1
console.log(y); // 2
console.log(z); // 3
Conditional operators (ternary) in
JavaScript
Use the ternary operator to create
concise conditional statements
arr.push(1, 2, 3);
arr.pop();
arr.shift();
arr.unshift(1, 2, 3);
Nested arrays and accessing/modifying
array data
Access nested array elements with
multiple indexes
Modify nested array elements by
assigning new values
Examples:
let arr = [[1, 2], [3, 4]];
console.log(arr[0][0]); // 1
arr[0][0] = 5;
console.log(arr); // [[5, 2], [3,
4]]
Destructuring assignment with arrays
Assign variables from array elements
with a destructuring syntax
Examples:
let arr = [1, 2, 3];
let [x, y, z] = arr;
console.log(x); // 1
console.log(y); // 2
console.log(z); // 3
Conditional operators (ternary) in
JavaScript
Use the ternary operator to create
concise conditional statements