1

Can anyone describe to which mechanism relates this behavior: When i try access to property of number

2.constructor

I get Uncaught SyntaxError: Invalid or unexpected token

When i try access to property of number in this way

(1).constructor

I get

ƒ Number() { [native code] }
Anton Krylov
  • 439
  • 1
  • 6
  • 17

1 Answers1

4

You need another dot to distinguish the first decimal separator from a dot as a property accessor.

console.log(2..constructor);
Mamun
  • 66,969
  • 9
  • 47
  • 59
Nina Scholz
  • 376,160
  • 25
  • 347
  • 392