I just run up into some code and then I did a test and found something I don't understand.
hey(
  () => {},
  () => {
    foo: "bar";
  }
);
Why the following syntax is a valid syntax? In the first argument, I can understand, because is an empty function scope, but in the second argument, how it doesn't give me an error?
If it's returning a object, it should be ({...}) and don't accept ; at the end, so this means that the second argument isn't an object.
If it isn't an object, what is it? Why it isn't a syntax error?
What black javascript magic is happening here?
Here is an example on codesanbox and it doens't give me any syntax error.
Edit
I just found some other weird thing.
hey(
  () => {},
  () => {
    "bar"; // without foo:
  }
);
How this doesn't give any error?
 
     
    