Dynamic Key Names with ES6 destructutinh

https://stackoverflow.com/questions/35939289/how-to-destructure-into-dynamically-named-variables-in-es6

by lasha

JavaScript

const fruits = ["🍎", "🍌", "🍐"];
const labels = ["apple", "banana", "pear"];

const newLabels = {};

for (let i = 0; i < fruits.length; i++) {
	({
    [fruits[i]]: newLabels[labels[i]] = fruits[i]
  } = fruits);
  console.log(newLabels);
}