Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
39
rated 0 times [  41] [ 2]  / answers: 1 / hits: 25255  / 12 Years ago, wed, february 20, 2013, 12:00:00
1 + undefined = ?  



  1. first, String(undefined) get string undefined

  2. second, 1 + undefined = 1undefined



what's wrong?



I run it in chrome console ,it return NaN.



can you pls explain the result?



I think it should be 1undefined.
tks


More From » javascript

 Answers
99

NaN is the result of a failed Number operation.



1 + undefined           // NaN
1 + undefined // 1undefined
1 + + undefined // 1undefined
1 + ( + undefined) // 1undefined
typeof NaN // number
typeof undefined // undefined
NaN === NaN // false (it's not reflexive!)
undefined === undefined // true (it's reflexive)
NaN.toString() // NaN


NaN means Not a Number where a number was expected. Any Number operation with NaN will result in NaN as well.


[#80106] Tuesday, February 19, 2013, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
deonkalvinw

Total Points: 409
Total Questions: 96
Total Answers: 89

Location: Saint Pierre and Miquelon
Member since Sun, Nov 27, 2022
2 Years ago
deonkalvinw questions
Sun, Feb 6, 22, 00:00, 2 Years ago
Tue, Dec 28, 21, 00:00, 2 Years ago
Sun, Aug 22, 21, 00:00, 3 Years ago
Sun, Mar 7, 21, 00:00, 3 Years ago
;