Javascript中变量之前的+运算符是什么?

tot*_*ten 10 javascript

我正在研究Raphael JS库,但我看到了这个:

Animation.prototype.delay = function (delay) {
    var a = new Animation(this.anim, this.ms);
    a.times = this.times;
    a.del = +delay || 0;
    return a;
};
Run Code Online (Sandbox Code Playgroud)

延迟变量之前的+运算符是什么?

谢谢.

Koo*_*Inc 17

如果可能,它将String变量转换为Number:+'21.2'equals Number(21.2).如果转换失败,则返回NaN(这是|| 0示例代码中的位置)


Yog*_*pta 7

如果变量有数字,这是一种将变量值设为数字的方法.替代你可以使用Number功能.