How to check value for NaN in JavaScript

preview_player
Показать описание
JavaScript returns NaN value when the value cannot be computed or as a result of attempted number coercion (type conversion) of non-numeric value (such that undefined) for which primitive numeric value is not available.

This video explains about NaN in JavaScript. Video explains popular NaN questions in JavaScript interviews such as,

What is NaN
What is the type of NaN
How to check for the NaN

JavaScript returns NaN in the following scenarios,

If one of the operands in an arithmetic operation is undefined
If one of the operands in an arithmetic operation is NaN
Dividing Zero by Zero
Dividing Infinity by Infinity
Multiplying zero with Infinity

You can check a value for NaN using

Рекомендации по теме
Комментарии
Автор

Thank you DJ for the detailed explanation. Perhaps the best video about NAN on the internet.

RahulGou
Автор

After watching this video I could replace NaN output with "0" string when I delete numbers in input number box. Thank you and them who created youtube.

rufatabbasov
Автор

NaN is an _error_ value with stands for
_Not a Number_, and it's type is number

const a = NaN;
console.log(typeof a);

Undecimberisbck
Автор

Thx bro, helped
Greetings from Russia :*

ember_arr
Автор

Thank you so much, im doing a calculator and i want to put a messague when they put a string, your code give me a solution, Greetings from Argentina

matics