Call methods on native Javascript types without wrapping with ()

前端 未结 5 1676
暗喜
暗喜 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

    Use the decimal point where the number expects it, and the dot operator will work as the object expects it.

    7.0.toFixed(0)

提交回复
热议问题