so in javascript interpreter puts a semicolon at the end of each line
Your assumption is wrong. It's easier to think of ASI as statement separation (which has nothing to do with lines!), because that's the intention and what it does. However, a bracket is not a new statement, so it will not be separated and instead interpreted as though it was a part of the previous statement.
So, the 2nd scenario is interpreted as though you would have written
var x = 10[1,2,4].forEach(console.log);
I recommend using a linter (like ESLint), which can mark problematic situations like that as warnings or errors in your code, so you can review and correct them before even running the code. Personally, I also recommend using semicolons, as that's how most languages work and you will find it a lot easier to learn them if you just use semicolons all the time.