[Javascript] Replace undefined with void 0

Zhentiw發表於2024-11-24

Why? Mainly due to undefinedis not a keyword, therefore you are able to create a variable called undefinedand assign it any value

let undefined = 10

Also undefinedis a global property in windowobject

'undefined' in window // true

Therefore there is recommendation that use void 0to repensent undefined.

相關文章