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

前端 未结 4 1044
萌比男神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

    Actually, comparing anything with undefined is not good idea at all. Should use typeof operator instead:

    function isUndefined ( variant ) { return typeof variant === 'undefined' }
    

提交回复
热议问题