Jump to content

angelahe

Members
  • Content Count

    1
  • Joined

  • Last visited

Community Reputation

0 Neutral

About angelahe

  • Rank
    Newbie
  1. In "JavaScript Operator", I noticed that the "var" keyword is not used when the += operator is used; for example: <p id="demo"></p> <script> var x = 10; x += 5; document.getElementById("demo").innerHTML = x; </script> And I tested the result of adding "var" before the statement x += 5, so: var x += 5, everything else uchanged. Then, it won't display 15; in fact, it displays nothing. However, if using x = x + 5 instead, adding or not adding "var", it always runs and displays 15. So, my questions are: (1) Why "var" cannot be used with += operator? (2) Why "var" seems to be operational when used with "x = x + 5"? Thank you!
×