Use of assignment operators in JavaScript

Source: Internet
Author: User
The assignment operations in JavaScript can be divided into simple assignment operations and compound assignment operations. The simple assignment operation is to save the value of the expression on the right of the assignment operator (=) to the left variable, while the compound assignment operation mixes other operations (such as arithmetic operations) and assignment operations. For example:

sum+=i;          //等同于sum=sum+i;

The assignment operators in JavaScript are shown in the following table.

For example, an employee's monthly salary of 5000 yuan, deduction of the total insurance costs of 500 yuan, the personal income tax threshold is 3500 yuan, the tax rate is 3%, calculate the actual income of the employee is how much. The code is as follows:

01  <script type="text/javascript">02  var salary = 5000;03  var insurance = 500;04  var threshold = 3500;05  var tax = 0.03;06  salary-=insurance;07  var salary1=salary;08  salary1-=threshold;09  salary1*=tax;10  salary-=salary1;11  document.write("该员工的实际收入为"+salary+"元");12  </script>

The result of the operation is:

该员工的实际收入为4470元

Use of assignment operators in JavaScript

Related Article

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.