I am trying to loop over a JavaScript object in ES6.
for (let [value, index] of object) {
do something with rest
if (index >= 1) {
// do something with first item
}
}
It works fine, although when I try to use index to get the first item it returns an error in console:
Uncaught TypeError: Invalid attempt to destructure non-iterable instance
Any ideas on how to loop over an object with index? thanks
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…