Js object key: plus value syntax

This question already has an answer here:

  • What does = +_ mean in JavaScript 12 answers

  • This is a unary conversion. It's a shorthand method to convert to a number. From the ECMAScript docs:

    The unary + operator converts its operand to Number type.

    The production UnaryExpression : + UnaryExpression is evaluated as follows:

    Let expr be the result of evaluating UnaryExpression.

    Return ToNumber(GetValue(expr)).

    var a = "45"; //typeof String
    a = +a; // now typeof Number
    
    链接地址: http://www.djcxy.com/p/73932.html

    上一篇: for循环迭代的这种替代方法是如何工作的? (JavaScript)的

    下一篇: Js对象键:加值语法