Why is NaN a global variable in JavaScript?

I noticed that it NaNis implemented as a global variable ( window.NaN) whose value NaN.

Why is this so? Wouldn't it be more reasonable for him to be a reserved word that represents a meaning, for example true, falseand null?

EDIT , apparently, is in the specification, along with undefinedand Infinity. WTF JavaScript ?!

+4
source share
2 answers

It is not just implemented in this way, it is specified in this way :

15.1.1 Global Object Value Properties

15.1.1.1 NaN

NaN NaN (. 8.5). {[[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false}.

15.1.1.2 Infinity

Infinity + ∞ (. 8.5). {[[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false}.

15.1.1.3 undefined

undefined undefined (. 8.1). {[[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false}.

( - .) , , .: -)

: , , , , - , ...:-) , : Infinity , - , . , . , , ...

+8

NaN - JavaScript, ( ) undefined .

. :

Nan and other global properties

, , . JavaScript JavaScript.

0

All Articles