Challenges, Tips & Tricks & Tutorials

# JavaScript Quiz – What actually negative infinity value returns

Contents

## Negative Infinity Value –

Negative Infinity value is a constant value, which is the lowest available value in javascript. That means, there is no value that is less than when compared to javascript negative infinity value.

Even if you compare with zero or less than zero, negative infinity value is always a winner.

For more detail on javascript negative infinity value.

## JavaScript Infinity Value –

JavaScript Infinity value is also a constant value & it’s just a reversed version of negative infinity value in javascript. Infinity value is the highest available value in the javascript.

Compare any positive value either number or float, infinity always win.

For more detail on javascript infinity value.

## JavaScript Question

In this javascript quiz, you need to find out what actually Infinity, 0 & -Infinity return when put it in an if conditional statement.

It’s all about does they return true or false to if.

Then first, we are putting a javascript Infinity value in if condition. So, if it true then it console log ”+ve“. But if it return false nothing going to print.

Then, we are putting a 0 in if condition. I hope you already know the answer of this statement.

Now, comes the interesting part what actually javascript negative infinity value returns.

Take a deep breath and think the solution of it.

## Explanation –

Now, you know the answer is “+ve” & “-ve“. But you have to know this also that why it gives “+ve” & “-ve” console.

So, let’s start with the first conditional statement which is Infinity. As it’s always a greater value and a positive number is always returned truthy.

That’s why we get our first console answer is “+ve“.

Now, for a second statement, it obviously returns false because 0 is a javascript falsy value. That’s why there is no console of “Zero

Last but not the least, -Infinity value what it returns as it’s less than any value means it’s lesser than 0. So, doesn’t it return false.

But it actually returns, true in if conditional statement. Because -Infinity comes under javascript truthy value. That’s why we got a console of “ve“.

I hope you enjoy this. But wait here is something more for you.

Check out our other javascript quiz –

## Conclusion

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.

13 Shares