【问题标题】:Space character before .toFixed method [duplicate].toFixed 方法前的空格字符[重复]
【发布时间】:2019-09-15 06:50:17
【问题描述】:

我注意到,如果您在 .toFixed 方法之前放置一个空格字符,它将不会出错。我明白为什么它可以与括号 (2).toFixed(2) 一起使用,但为什么它可以与空格一起使用?

console.log(2 .toFixed(2))
// 2.00
console.log(2.toFixed(2))
// Uncaught SyntaxError: Invalid or unexpected token

请留下任何有关此信息的链接。谢谢。

【问题讨论】:

  • console.log(2..toFixed(2)),第一个作为小数点

标签: javascript numbers tofixed


【解决方案1】:

它只是(点)运算符之前的常用空格。

也许你也看看这里:dot notation

console.log(2 .toFixed(2))

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-08-05
    • 2016-04-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多