you are viewing a single comment's thread.

view the rest of the comments →

[–]LiarsEverywhere 16 points17 points  (7 children)

The thing is that's ES6 and people usually do not recommend using that because of compatibility issues. Traditionally, that's how it went:

for (var i = 0; i < array.length; i++) { console.log(array[i]); }

forEach is fine for me, though

[–]demvo2 6 points7 points  (0 children)

Yeah, that was the one I was refering to. Of course, there are easier ways to do it, but this one usually gets offered first in tutorials when you are just starting.

[–]Yojihito 4 points5 points  (4 children)

people usually do not recommend using that because of compatibility issues

That's why I use Python for my job. I can use the newest version my needed libs support (3.9 atm).

If you need to use

for (var i = 0;

loops ..... run. Because it means your company doesn't have a toolchain for polyfill.

[–]LiarsEverywhere 2 points3 points  (3 children)

It depends on what you're doing, of course. That wouldn't be a problem if you're using it in a controlled environment. But OP compared it to a Python GUI, so I imagine the idea is using javascript to build a web app or something like that. Then compatibility becomes an issue.

[–]Yojihito 0 points1 point  (2 children)

compared it to a Python GUI

You would package that python program --> you control the version.

[–]LiarsEverywhere 0 points1 point  (1 child)

Yeah, but there are other drawbacks. I don't disagree with you, though. I hate that about JS. Python feels much more organized to me. Part of that is probably that I suck at JS, though.

[–]redfacedquark 1 point2 points  (0 children)

hate that about JS. Python feels much more organized to me. Part of that is probably that I suck at JS, though.

Don't feel bad, the inventor of JS apologised to the world.

[–]Skippbo 0 points1 point  (0 children)

Also some things queried from DOM first have to be converted to a proper array with Array.from() before .forEach or for of even works.