The ASI (automatic semicolon insertion) in JS doing its job here actually causes a bug. The value being returned should begin on the same line, or else foo2 gets compiled down to this:
functionfoo2(){return;{bar:'World'}}
This can be fixed by telling JS to start at the next line after the return by using parens
functionfoo2(){return({bar:'World'});}
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
foo1returns an object as expectedThe ASI (automatic semicolon insertion) in JS doing its job here actually causes a bug. The value being returned should begin on the same line, or else foo2 gets compiled down to this:
This can be fixed by telling JS to start at the next line after the return by using parens