JavaScript variables have either global or local scope. A global variable in a Web browser is typically initialized in var statements that execute as the document loads. All statements in that document can read or write that global variable. Only statements inside that function may access that local variable. Scripts sometimes access JavaScript static object properties and methods.
Some static objects encourage direct access to their properties or methods.
You can add properties or methods to working objects at will. To add a property to an object, simply assign a value of any type to it. Inside the function definition, the this keyword refers to the object that owns the method. JavaScript objects employ prototype-based inheritance. All object constructors create working objects whose properties and methods inherit the properties and methods defined for the prototype of that object.