Example 1 — Division by zero
Yields Infinity, not an exception.
JavaScript
console.log(1 / 0); How It Works
- IEEE floating-point rules.
Arithmetic operators compute numbers: +, -, *, /, % (remainder), and ** (exponent). + also concatenates when a string is involved.
console.log(2 + 3);
console.log(10 % 4);
console.log(2 ** 3);
console.log("2" + 3); Yields Infinity, not an exception.
console.log(1 / 0); Increment operators.
let n = 1; console.log(++n); Convert strings to numbers.
console.log(+"42"); CODETOFUN NEWS
Get the latest IT news, programming updates, and technology trends directly on your phone.
Your daily dose of tech, straight to your feed.
6 people found this page helpful