The Wayback Machine - https://web.archive.org/web/20240118165816/https://www.geeksforgeeks.org/division-assignment-operator-in-javascript/
Open In App
Related Articles

Division Assignment(/=) Operator in JavaScript

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Report issue
Report

JavaScript Division Assignment Operator in JavaScript is represented by “/=”. This operator is used to divide the value of the variable by the value of the right operand and that result is going to be assigned to the variable. This can also be explained as dividing the value of the variable by an expression and assigning that result to the variable.

Syntax:

a /= b
or
a = a / b

Example 1: In this example, we will use the division assignment operator.

Javascript




let x = 18;
x /= 3;
console.log(x);
  
x /= 2;
console.log(x);
  
x /= 0;
console.log(x);



 

Output

6
3
Infinity

Example 2: In this example, we will use the division assignment operator.

Javascript




let a = 18;
a /= 3;
console.log(a);
  
a /= 'bar';
console.log(a);


Output

6
NaN

We have a complete list of Javascript Assignment Operators, Please check this article Javascript Assignment Operator.

Supported Browser:

  • Chrome 1
  • Edge 12
  • Firefox 1
  • Opera 3
  • Safari 1
Learn to code easily with our course Coding for Everyone. This course is accessible and designed for everyone, even if you're new to coding. Start today and join millions on a journey to improve your skills!

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Commit to GfG's Three-90 Challenge! Purchase a course, complete 90% in 90 days, and save 90% cost click here to explore.
Last Updated : 23 May, 2023
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads
Complete Tutorials