2

(1) 和 1 有什么区别。

1.toString() //Will throw error
1.toFixed(1) //Will throw error
(1).toString() // output "1"
(1).toFixed(1) // output 1.0
4

1 回答 1

6

尾随句点1.是数字的一部分——编译器将其读取为小数点,而不是点运算符。这使得紧跟在数字后面的标识符是意外的。

考虑一下,进行比较:1.0toString()

于 2017-01-28T03:02:07.290 回答