I read some article said following 5 cases has no ASI. The first 4 cases are easy to understand but I don't get the 5th case. Why is the 5th case valid ?
//1. treated as plus operation
a = b
+a
//2. treated as minus operation
a = b
-a
//3. treated as division operation
a = b
/something/.test(a)
//4. treated as function invocation
a = b
(function () {})()
//5. treated as property access
a = b
[1, 2, 3].forEach()
Another example for that is the function expression
a = function() {
}
[1,2,3].forEach(function(item) {
});
//It will be interpreted as following, but why is this valid at all?
a = function() {
}[1,2,3].forEach(function(item) {
});
Why is it valid for function express at all ? Why just add ASI for square bracket?
PS, I did read What are the rules for JavaScript's automatic semicolon insertion (ASI)? before I asked my question. But I don't see that answer my question about square bracket, especially for function expression