Automatic semicolon insertion & return statements [duplicate]
问题 This question already has answers here : What are the rules for JavaScript's automatic semicolon insertion (ASI)? (5 answers) Closed 4 years ago . As you might know, ECMAscript tries to be smart and will automatically insert semicolons if you didn\'t write those explicitly. Simple example function foo() { var bar = 5 return bar } will still work as expected. But there are some caveats if you rely on that. If we re-write that function like so function foo() { var bar = 5 return { bar: bar } }