JS: What's the difference between =+ and +=

This question already has an answer here:

  • Difference between += and =+ in javascript 1 answer

  • =+ will cast implicitly x to a number and assign sumX the value

    += will add x to sumX without an attempt at casting


  • sumY += y; adds y to sumY .
  • sumY =+ y; is equivalent to sumY = (+y); . For numbers, the unary plus operator is a no-op, so the entire expression simply assigns y to sumY .
  • 链接地址: http://www.djcxy.com/p/73886.html

    上一篇: `1L`和`1`有什么区别?

    下一篇: JS:= +和+ =有什么区别