
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What happens when we try to add a number to undefined value?
If you try to add a number to undefined value then you will get a NaN. The NaN defines Not a Number. Following is an example −
Case 1
var anyVar=10+undefined; print(anyVar) //Result will be NaN
Case 2
var anyVar1=10; var anyVar2; var anyVar=yourVar1+yourVar2; print(anyVar) //Result will be NaN
Case 1
Let us implement the above cases. The query is as follows −
> var result=10+undefined; > print(result);
This will produce the following output −
NaN
Case 2
Let us implement the above case −
> var value; > var value1=10; > var result=value1+value > result
This will produce the following output −
NaN
Advertisements