Division (/) Operator
Use the division operator, represented in JavaScript by the symbol (/), to divide two integers. Two operands may be divided; the divided operand is known as the “dividend,” while the dividing operand is referred to as the “divisor.” The “quotient” is the value that remains after division. Follow the given-provided syntax for division:
dividend/divisor;
Example 1: In this example, we will use an integer dividend with an integer divisor. Assigning integer values to the two integers “a” and “b,” we shall divide them in this example. Then, when “b” is a divisor, use the console.log() function with “a” as a dividend:
Javascript
const a = 14; const b = 2; console.log(a / b); |
7
Example 2: In this example, we will use an integer dividend with a float divisor. Now, we’ll divide the integer value by the float value, where “a” is equal to “123” and “b” is equal to “1.7”:
Javascript
const a = 123; const b = 1.7; console.log(a / b); |
72.3529411764706
Division in JavaScript
In every programming language, the operation of division is used often. The division operator (/) is used in JavaScript to divide integers. You may use the division operator or a predefined JavaScript technique that treats every number as an integer to divide two values.
Use the techniques listed below to divide two numbers:
Table of Content
- Division (/) Operator
- JavaScript parseInt() Method
- Using math library in JavaScript
- Using Bitwise Operator