Note 01: Pre-increment after increment i++;++i;

Source: Internet
Author: User

Before looking at the video course, it is not clear before the increment, after the increment, the amount of pre-decrement, after the reduction of the piece, this now know what happened, need to record down so that later.

  1. var m = 10;
  2. var n = 8;
  3. alert (++m); 11
  4. alert (n++); 8
  5. Alert (m); 11
  6. Alert (m); 9

The pre-increment is calculated before executing the statement that contains the variable m, after which the increment is naturally calculated after executing the statement, so the Code line fourth pops up 8, and the sixth line POPs 9;

The corresponding amount of pre-decrement and post-decrement is also the reason.

The JavaScript Advanced Programming book indicates

Note 01: Pre-increment after increment i++;++i;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.