How to use Division Assignment Operator In Javascript
This “/=” operator is used for division where we divide the variable’s value present in the left side to the value or variable present in the right side and that result get stored in left variable itself.
Syntax:
leftOperand /= rightOperand;
Example: This example decribes division of two numbers using Division assignment operator
// Creating a variable having value 40
let x = 40;
// Using subtract-and-operator
x /= 10.0;
// Printing the result
console.log(x); // 4
Output
4
JavaScript Program for Division of Two Numbers
In this article, we will see the basic approaches for the division of two numbers in JavaScript. The division is used in many languages, In JavaScript it can be done using some operators or some other methods.
Javascript has no data type such as integer, float, or double so we can directly use them via letting variables directly.
Example:
Let's take two numbers :
a = 10
b = 5
here , a is dividend and b is divisor
a / b = 10 / 5 = 2
These are the following ways by which we can divide two numbers:
Table of Content
- Using Division / Operator
- Using Functions
- Using Arrow function
- Using Division Assignment Operator
- Using Math.floor() for Integer Division
Contact Us