3 ms·
You can try the following in a browser's JS console or in a NodeJS REPL: > for (const x of [1,2,3]) { console.log(x); } 1 2 3 undefined >
by michaelsbradley 7y ago
You can try the following in a browser's JS console or in a NodeJS REPL:
> for (const x of [1,2,3]) { console.log(x); }
1
2
3
undefined
> for (const x of {a:1,b:2,c:3}) { console.log(x); }
TypeError: {(intermediate value)(intermediate value (intermediate value)} is not iterable
So, sometimes JS automatically performs type conversions. But it also has the same kind of type-related runtime errors as Python. It just depends what you're doing.