Skip to content

Commit 905297e

Browse files
committed
infinityfaq
1 parent 329c088 commit 905297e

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

Linkdin Post/Js/infinity.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
2+
3+
/*Definition:
4+
Infinity is a special numeric value in JavaScript that represents something larger
5+
than the maximum possible number.
6+
7+
It is a global constant.
8+
9+
*/
10+
11+
let a=10/0
12+
console.log(a)//Infinity
13+
14+
/*
15+
Note:
16+
Infinity is not an error
17+
18+
Operations with Infinity often result in Infinity or NaN
19+
*/
20+
console.log(Infinity === Infinity); // true
21+
console.log(isFinite(Infinity)); // false
22+
23+
console.log(Infinity - 1 *8-5); // Infinity
24+
console.log(Infinity - Infinity); // NaN
25+
console.log(1+Infinity) //Infinity
26+
27+
28+
29+
console.log(1 / 0); // Infinity
30+
console.log(-1 / 0); // -Infinity
31+
console.log(Number.MAX_VALUE * 2); // Infinity
32+
33+
let x = 5;
34+
if (x < Infinity) {
35+
console.log("x is less than Infinity");
36+
}
37+

0 commit comments

Comments
 (0)