Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我注意到,如果您在.toFixed方法之前放置一个空格字符,它将不会出错。我理解为什么它与括号一起使用(2).toFixed(2),但为什么它与空格一起使用?
.toFixed
(2).toFixed(2)
console.log(2 .toFixed(2)) // 2.00
console.log(2.toFixed(2)) // Uncaught SyntaxError: Invalid or unexpected token
请留下任何有关此信息的链接。谢谢。
它只是(点)运算符之前的常见空格。
也许你也看看这里:dot notation
console.log(2 .toFixed(2))