Call methods on native Javascript types without wrapping with ()

前端 未结 5 1715
暗喜
暗喜 2021-01-14 08:22

In Javascript, we can call methods on string literals directly without enclosing it within round brackets. But not for other types such as numbers, or functions. It is a syn

5条回答
  •  难免孤独
    2021-01-14 08:44

    The lexer is expecting a decimal value when it sees a number immediately proceeded by a period. Though you could get "creative" and put a space between the number, as in 7 .alert() but people would probably hunt you down for it when they get stuck maintaining your code!

提交回复
热议问题