This Refer
code in module and class enable strict mode by default
browser
globalThis
always refer towindow
this
in global within strict or non-strict mode refer towindow
this
in non-arrow function refer towindow
within non-strict mode, refer toundefined
within strict modethis
in arrow function refer to it parent domainthis
- variable declared with
var
in global is seted towindow
- variable defined without declaring is seted to
window
within non-strict mode, and will throw error within strict mode
nodejs
globalThis
always refer toglobal
this
in global within strict or non-strict mode refer to plain object {}, notice: not global objectthis
in non-arrow function refer toglobal
within non-strict mode, refer toundefined
within strict modethis
in arrow function refer to it parent domainthis
- variable declared with
var
in global is not seted to global - variable defined without declaring is seted to
global
within non-strict mode, and will throw error within strict mode