Destructuring for-in loop has been removed

Published: | Categories: JavaScript


The non-standard implementation of destructuring loops in JavaScript 1.7, like for (var/let/const [key, value] in object), has been removed. For an Array or other iterable objects, you can simply use the for...of loop instead. For a general Object, you can also use the for...of loop in combination with Iterator, like for (let [key, value] of Iterator(object)), but unfortunately the non-standard Iterator will also be removed in the future. Therefore, a realistic solution might be for (let key in obj) { let value = obj[key]; }.