Why 'NaN' and 'Undefined' are not reserved keywords in JavaScript?

后端 未结 5 1028
野的像风
野的像风 2020-12-03 16:52

We can do:

NaN = \'foo\'

as well as

undefined = \'foo\'

Why are they not reserved keywords?

Edit

5条回答
  •  悲&欢浪女
    2020-12-03 17:44

    Both NaN and undefined are values in JavaScript.

    1. NaN is of number type. (it denotes "not a valid number").
    2. undefined is of undefined type. (when there is nothing assigned to a variable, JavaScript assigned undefined particular in var declaration).

    And also both are read-only values(property) of global window object.

    So that's why JavaScript cannot make values as a reserved word.

提交回复
热议问题