BY Simmi Kava17 Mar 2021 Edit
Null and NaN

JavaScript Oddities - Null and NaN

console.log(typeof null) //object
console.log(null instanceof Object) //false

We all know that value null represents intentional absence of any object value. typeof would return a string, hence typeof null returns object. This is a historical bug (since the first version of JavaScript) and cannot be fixed.

But since null is absence of value, it implies it cannot be instance of anything, hence instanceof returns a false value.

Similarly,

console.log(typeof NaN) //Number
console.log(NaN === NaN) //false

NaN is a number from data type point of view. NaN is a special number as specified by IEEE format specification and is not JavaScript language specific. NaN is never equal to NaN, as each NaN is unique unknown number.

BY Simmi Kava
1 Like1 Save
LikeCommentSave
LikeCommentSaveShare
1

POPULAR POSTS
17 Mar 2021
LATEST ACTIVITY
srikanth.naidu
liked this post.
malli
saved this post.
Show more
ARCHIVES
2021
2020
2019
2018
TAGS
javascript (41)
developer (25)
javascriptdeveloper (15)
coding (10)
Xamarin.Forms (10)
webatoms (8)
arrays (7)
xamarin (7)
android (6)
typescript (6)
function (5)
csharp (4)
iOS (4)
methods (4)
object (4)
update (4)
web-atoms (4)
arrayoperation (3)
decorators (3)
programming (3)
prototype (3)




Web Atoms: JSX (TSX + TypeScript) for Xamarin.Forms, Hot Reload Your App in Production Environment

PlaygroundSamples Repository