Tim
Tim

Reputation: 99418

Are all the global variables and global functions members of the `window` object?

When using JavaScript in a browser on a webpage,

If the answer(s) is no,

Upvotes: 1

Views: 85

Answers (1)

Jonas Wilms
Jonas Wilms

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

Related Questions