I don't think you can detect whether the denominator is zero except by evaluating it as it might be expressed as (5*2/10-1)

JavaScript does not give an error on division by 0, but you can detect divison by zero resulting in infinity easily enough:-

Code:

<script type = "text/javascript">
function divByZero(dividend,divisor) {
var quotient=dividend/divisor;
if(isNaN(quotient)) return 0; // can be changed to whatever is desired by the programmer to be 0, false, or Infinity
if (Math.abs(quotient) === Infinity) {
alert ("The result is +- infinity");
}
return quotient; //Will return Infinity or -Infinity in cases of, for example, 5/0 or -7/0 respectively
}
alert(divByZero(5,0));
</script>

The Dutch have a good record against Holland. - Commentator, ITV1