I have Data Structure like this
const array = [
[["first_name" , "First"], ["image" , "image"]],
[["email" , "email"]],
[["last_name","last_name"]],
[["password" , "password"], ["password", "password"]]
]
My Iterator Implementation is
let arr = array.values();
let obj = {
[Symbol.iterator]: function () {
return {
next() {
for (const iterator of arr) {
for (let [, value] of iterator) {
return {
done: false,
value,
};
}
}
return {
done: true,
};
},
};
},
}
But when I iterate it [...obj]
I am getting Only first element of 2D array
The output I am getting is ["First" , "email" , "last_name" , "password"]
Expected output ["First" , "image" , "email" , "last_name" , "password", "password"]
Nested for..in iterate only 1st element of nested array
Note:- Above solution is working fine with Symbol.Iterator generator function