Why is "fontSize: 72px" wrong

{ fontSize: 72px } ← Syntactically 72px looks like an identifier. But it’s a syntactically incorrect one (identifiers can’t start with numbers). That’s the problem.

In fact it gives you a descriptive error message:

SyntaxError: unknown: Identifier directly after number.


{ fontSize: '72px' } ← In this case '72px' is a string literal, JS doesn’t look anything up, there’s no problem.

1 Like