Coming from a Python background, I am embarking on the journey to learn basic concepts in JavaScript.
Currently, I have the following code snippet:
{
name: 'Jobs ',
path: '/plat/jobs',
meta: {
label: 'jobs',
link: 'jobs/Basic.vue'
},
My goal is to create this block for each element in a list using a for loop (including the curly brackets).
In Python, achieving this would look something like:
for i in items:
{
name: i.name,
path: i.path,
meta: {
label: i.label,
link: i.link
}
How can I accomplish this in JavaScript? What exactly is the data type of this object? Is it simply a JavaScript dictionary?
children: [
let new_items = items.map(i => ({
name: i.name,
path: i.path,
meta: {
label: i.label,
link: i.link
}
}));
console.log(new_items);
component: lazyLoading('android/Basic')
}
]
}
I suspect that this approach won't work as I need each object listed under children individually.