Tagged articles

Symbol.iterator

2 articles · Page 1 of 1
IoT Full-Stack Technology
IoT Full-Stack Technology
Jun 18, 2026 · Fundamentals

How to Make var [a, b] = {a:1, b:2} Work in JavaScript?

This article explains why the destructuring statement var [a, b] = {a:1, b:2} throws a TypeError, explores the iterator protocol and Symbol.iterator, and shows how redefining Object.prototype[Symbol.iterator] enables the object to be iterable so the destructuring succeeds.

DestructuringInterview QuestionIterator Protocol
0 likes · 6 min read
How to Make var [a, b] = {a:1, b:2} Work in JavaScript?
IoT Full-Stack Technology
IoT Full-Stack Technology
Jun 17, 2026 · Interview Experience

How to Make var [a, b] = {a: 1, b: 2} Work in JavaScript?

The article explains why the destructuring statement var [a, b] = {a: 1, b: 2} throws a TypeError, details the iterator requirement for the left‑hand side, and shows how to add a Symbol.iterator method to Object.prototype so any object becomes iterable and the assignment succeeds.

DestructuringInterview QuestionIterator Protocol
0 likes · 6 min read
How to Make var [a, b] = {a: 1, b: 2} Work in JavaScript?