To easily extract values from an object, use destructuring

const obj = {x: 1, y: 0, width: 10, height: 12};

const {x, y} = obj;
console.log(x, y) // 1 0 

To assign an extracted variable to a new variable name, you can do the following:

const obj = { "obj value": "hello" };

const { "obj value": newValue } = obj;
console.log(newValue === "hello") // true

Array Destructuring

let array = [1, 2, 3, 4];
let [a, b, c, d] = array;

Tip: To swap two variables without using a third one, use typescript solution

let x = 1, y = 2;
[x, y] = [y, x];
console.log(x, y); // 2, 1

Array destructuring with ignores

You can ignore any index by simply leaving its relavent location empty.

const [x, , ...remaining] = [1, 2, 3, 4];
console.log(x, remaining); // 1, [3,4]
const array = [ 1, 2, 3, 4, 5 ];

const [a, , , , b] = array;

console.log(a, b); // 1, 5