course content

Course Content

Introduction to JavaScript

Operations with AssignmentOperations with Assignment

The readability of the code is very important, so now we will consider the possibilities to make the code more beautiful.

There are math operations with the assignment:

  • addition assignment (+=);
  • subtraction assignment (-=);
  • multiplication assignment (*=);
  • division assignment (/=);
  • remainder (modulo) assignment (%=);
  • exponentiation assignment (**=).

Assignment operators are used to improve code readability.

Look at the example:

The expression a += 5 replaces the a = a + 5.

Let's look at other replacement to understand how it works:

with assignmentdefault
a += 6a = a + 6
a -= 6a = a - 6
a *= 6a = a * 6
a /= 6a = a / 6
a %= 6a = a % 6
a **= 6a = a ** 6

Section 3.

Chapter 3