Skip to content

Instantly share code, notes, and snippets.

@timrprobocom
Created February 22, 2022 17:44
Show Gist options
  • Save timrprobocom/da552a4857650c9209f3e383e258dc27 to your computer and use it in GitHub Desktop.
Save timrprobocom/da552a4857650c9209f3e383e258dc27 to your computer and use it in GitHub Desktop.
// I seriously doubt this is your actual data structure.
const data = [
[name = 'john doe', name2 = 'hello'],
[age = 23],
[hobby = [{
name: 'mancing'
}]]
];
data.map((item, key) => console.log(item, key))
// The embedded names in those arrays are not "keys". That's just a cheap
// way of creating new variables. So, what you have written is exactly the
// same as this:
name = 'john doe';
name2 = 'hello';
age = 23;
hobby = [{name: 'mancing'}];
const data = [
[name, name2],
[age],
[hobby]
];
// And that seems wrong.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment