Bootstrap

How to make Infinity!

MAFEE7 Aug 4 ・1 min read

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 returns NaN

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)}`)
Enter fullscreen mode Exit fullscreen mode

So if you just use

   "9".repeat(999)
Enter fullscreen mode Exit fullscreen mode

It will return something like this:
image
More the 9's more the number's digits! (But I used 999)

Now, parseInt converts the string with the 999 9's into an integer. The integer is so big that javascript treats it like Infinity!

Yay we got Infinity in javascript!

😳 I found this when trying to make a string with millions of Hi!s

Hot Articles

Feedback on requirements and issues

If you have a good web tool that you would like to put on this site for use, please write down your github address and we will contact you!