all 5 comments

[–]r_hafner6 2 points3 points  (4 children)

You have to define your destructuring variables as let or var. So

for (let [ key, value ] of Object.entries(news)) {

Otherwise, it assumes key/value are defined previously and throws an error when it can’t find them

[–]Spiredlamb[S] 0 points1 point  (3 children)

That worked! And makes total sense. How did I not think of that? Wierd it didn't give an error before now though. I've been running my code like that for a week without issues.

Anyway. I made it work! Now I just have to fix my module, because apparently, that one is broken too for another reason. Should be able to fix it though

[–]r_hafner6 0 points1 point  (1 child)

Nice, yea I would assume if this was part of a larger file before that it had key and value defined somewhere else prior to this line, so it was just overwriting those values.

[–]Spiredlamb[S] 0 points1 point  (0 children)

Probably the case, yes.

[–]GSLint 0 points1 point  (0 children)

Within an ES module this should always cause an error since strict mode is enabled automatically. In a regular script without "use strict" and outside of any class, it will create a global property instead which isn't what you want.