JavaScript 中的加法赋值运算符 (+=) 是什么?

javascriptweb developmentfront end technology

它将右操作数添加到左操作数,并将结果赋值给左操作数。

示例

您可以尝试运行以下代码来了解如何使用加法赋值运算符 −

<html>
   <body>
      <script>
         var a = 33;
         var b = 10;

         document.write("Value of a => (a += b) => ");
         result = (a += b);
         document.write(result);
         document.write(linebreak);
      </script>
   </body>
</html>

相关文章


有用资源