0

function A() {
  return {
    'name': "a"
  };
}

function B() {
  return 
  {
    'name': "b"
  };
}

console.log(A());
console.log(B());

On my browser this code generates the following error

Uncaught SyntaxError: Unexpected token :

Browser Google Chrome:

Version 74.0.3729.131 (Official Build) (64-bit)

As far as I know JavaScript accepts an end statement after the return statement.

What makes the first return an end statement but not the second?

Oussama Ben Ghorbel
  • 2,132
  • 4
  • 17
  • 34

0 Answers0