# Javascript Divide by Zero Check
In JavaScript, division by zero does not cause an any error. While, it generates Infinity, which is a reserved word in JavaScript.
Let's try to create simple example:
If the division number is positive then it generates positive Infinity.
Example 1 : divided by zero;
In this code, we will divide the positive integers by 0.
- <script type="text/javascript">
var a = 10, b= 0;
var division;
division = a / b;
console.log(division);
- </script>
Output :
Infinity
If the division number is negative then it generates negative -Infinity.
Example 2: divided by zero;
In this code, we will divide the negative integers by 0.
- <script type="text/javascript">
var a = -10, b= 0;
var division;
division = a / b;
console.log(division);
- </script>
Output :
-Infinity
Comments