JavaScript saves and calculates the number type variables in the page

  • 2020-07-21 06:33:05
  • OfStack

Previously, the html page was embedded with the following javascript fragment, but the i value is increased by 1 when 1 button is clicked, but the initial value of i remains unchanged after two clicks.


<script language=javascript>
      var i=2;
</script>


The variable is then declared in an test object as follows. This allows the value of test. i to be saved every time test. i is changed


<script language=javascript>
      var test={};
      test.i=2;
</script>


Related articles: