Reputation: 99418
When using JavaScript in a browser on a webpage,
are all the global variables and global functions members of the window
object?
are all the members of the window
object global variables and global functions?
If the answer(s) is no,
what kinds of global variables and global functions are members of the window
object? What kinds are not?
what kinds of members of the window
object are global variables and global functions? What kinds are local?
Upvotes: 1
Views: 85
Reputation: 138257
are all the global variables and global functions members of the window object?
All global variables declared with var
and functions (and all variables that are not declared at all (!¹)) are.
are all the members of the window object global variables and global functions?
Yes. The window
variable itself is actually just a property of the window object (undefined
and NaN
too ... they aren't keywords...).
All the default properties of the window object are
1) the global object properties according to the ES spec
2) window specific properties according to the Web spec
¹ You should always declare your variables. You should always use let
/ const
in favor of var
(because var name = 12; console.log(typeof name)
surprises you otherwise). And you should "use strict;"
mode which prevents undeclared variables.
Upvotes: 2