New Method to make Infinity
!
So... I found a new way to make
Infinity
in Javascript!
This is how:
Using
parseInt()
with.repeat()
! 🤣
Meaning of parseInt()
parseInt()
basically converts a string into Integer. If some invalid string is passed (like: "hi"), it returnsNaN
Meaning of .repeat()
string.repeat()
returns the same string but repeated the number of times given!
Using it to make Infinity
∞!
Code:
parseInt(`${"9".repeat(999)}`)
So if you just use
"9".repeat(999)
It will return something like this:
More the 9's more the number's digits! (But I used999
)Now,
parseInt
converts the string with the999
9's into an integer. The integer is so big that javascript treats it likeInfinity
!Yay we got
Infinity
in javascript!