Get 'undefined' if 'window.undefined' is overwritten

前端 未结 4 1046
萌比男神i
萌比男神i 2020-12-30 08:46

It appears that window.undefined is writable, i.e. it can be set to something else than its default value (which is, unsurprisingly, undefined).

4条回答
  •  春和景丽
    2020-12-30 09:16

    It's should be enough to just declare a variable without assigning it to anything:

    var local_undefined;
    alert(typeof local_undefined);
    

    But why on Earth is it possible to change undefined value? Does anyone know history behind this?

提交回复
热议问题