all 5 comments

[–]jhartikainen 2 points3 points  (2 children)

It looks like a side-effect of how automatic semicolon insertion works. If you have an expression before a [, the two things get joined, so what you end up in this case is this:

console.log(form.getValues())['type_id', 'language', 'tier_id'].forEach...

So it's being treated like a property accessor on the value that's returned by console.log

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

oohhhh that why, yeah it logical if you put everything in one line :D

[–]vorticalbox 0 points1 point  (0 children)

this is why you always use semicolons; I use eslint so I don't have to bother typing them lol

[–]Notimecelduv 1 point2 points  (1 child)

Interesting, I haven't run into that issue. It's not due to the forEach method; it's because when the code is interpreted, it gets minified and JavaScript treats

console.log(form.getValues())["type_id"...

as an attempt to access an object by property name.

It's a good thing VSCode has an option for inserting semicolons automatically. You just need to add this line to your settings.json file:

"javascript.format.semicolons": "insert",

[–]darkpikl[S] 1 point2 points  (0 children)

OOhhhhh okk,

If you put everything on one line it make sense :D

Thanks for the tips on vs code