The divide operator is represented by a slash `/`

.

var result = 6 / 2; console.log(result);

If either of the operands isn't a number, it is converted to a number behind the scenes using the Number() casting function. This means that an empty string is treated as 0, and the Boolean value of true is treated as 1.

The divide operator has special behaviors for special values.

The divide operator has special behaviors for special values.

Operand | Result |
---|---|

If the operands are numbers | regular arithmetic division is performed.two positives or two negatives equal a positive.operands with different signs yield a negative.If the result can't be represented in ECMAScript, it returns either Infinity or -Infinity |

If either operand is NaN | result is NaN |

If Infinity is divided by Infinity | the result is NaN |

If zero is divided by zero | the result is NaN |

If a nonzero finite number is divided by zero | the result is either Infinity or -Infinity, depending on the sign of the first operand |

If Infinity is divided by any number | the result is either Infinity or -Infinity, depending on the sign of the second operand |

If either operand isn't a number | it is converted to a number behind the scenes using Number() and then the other rules are applied |