JS Startup

Challenges, Tips & Tricks & Tutorials

JavaScript Quiz – Infinity number is a true or false value

JavaScript Quiz – Infinity number is a true or false value

JavaScript Infinity –

The javascript infinity is a global property which is a numeric value representing infinity.

That means there is no number greater than the infinity when compared with infinity. The initial value of Infinity is Number.POSITIVE_INFINITY.

It’s syntax looks like –


For more detail about JavaScrip Infinity click here.

JavaScript Question

In this javascript quiz code, you need to find does infinity number is a true or false value when compared with boolean value.

First, we declare a variable number with let keyword and assign Infinity value to number variable.

let number = Infinity;

In the second step, we are comparing a variable number with the boolean value true to check whether it returns true or false. A

console.log(number == true); // output => ?

Now in the next step, we use a not operator with number variable and print the output using console log.


Any guess what is the output of above two statements ?

Answer – false, false

Click To Run Code


Now, you know the answer is “false, false“. But why it giving false for both cases if first case giving false then last should give true.

So, for the first console log statement, it gives false because it’s clearly seen that number which has an Infinity value not equal to true.

JavaScript Not Operator (!)

Now, in the next step when we use console log with number with ! not operator.

So, not operators convert the value to boolean as Infinity is a truthy value so when not-operator used with it converted to a false value.

At last, That’s why we get an answer “false, false“.

Let me know in the comment section, what you think about it.

I hope you understand the concept and logic behind it.

But wait, i have something more for you –

Check out our other javascript quiz – 

  1. JavaScript Quiz – does arguments is a default function parameter
  2. JavaScript Quiz – object seal method can restrict value change
  3. JS Quiz – can string split method will be limited
  4. JS Quiz – can array from method be like a map method


To participate in our javascript quiz or challenges, tutorial, tips & tricks make sure to join our jsstartup newsletter. So, you can able to participate in our daily challenges & learn the javascript concept.

And last but not the least, don’t forget to like, comment and share. It gives us a morale boost to remain to continue. Also, join our Facebook Page

If you have any questions, please feel free to ask me in the comment section and also let me know if you have any suggestions. As suggestions are always welcome.

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top
Share via
Copy link