79115181

Date: 2024-10-22 17:28:22
Score: 1
Natty:
Report link

The "statements vs expressions" response would be a neat answer, but then why are commas used for object declaration

let obj = {prop_a: 1, prop_b: 2}

while semicolons are used for class declaration

class Obj {prop_a: 1; prop_b: 2}

?

Declaring the object with a semicolon throws the SyntaxError Unexpected token ';', while declaring the class with a comma throws a different SyntaxError Unexpected identifier 'prop_a'.

Reasons:
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • Low reputation (1):
Posted by: emarg