Waterfr Villa
Waterfr Villa

Reputation: 1317

Global variable’s properties’ scope

Let’s say we have a global variable defined as follows:

gContainer = {};
gContainer.person = {
   name: "Jack",
   last_name: "Tompson"
};

Are its properties global too? I mean, is person global too?

Upvotes: 0

Views: 33

Answers (2)

Rahul Tripathi
Rahul Tripathi

Reputation: 172518

Are its properties global too? I mean, is person global too?

No. gContainer.person is a property to an object not a global variable

Upvotes: 1

Ry-
Ry-

Reputation: 225054

No. The term “global” only applies to variables, and gContainer.person is not a variable; it’s a property of an object.

Upvotes: 5

Related Questions