Created
February 22, 2022 17:44
-
-
Save timrprobocom/da552a4857650c9209f3e383e258dc27 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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