JavaScript looks up an unqualified name by searching a scope chain associated with the execution context of the script or function containing that unqualified name. The with statement adds the given object to the head of this scope chain during the evaluation of its statement body. If an unqualified name used in the body matches a property in the scope chain, then the name is bound to the property and the object containing the property.