If you take a look at this fiddle in Chrome and click the Trigger text with the js console open you will see this:

What is the reason of all those with blocks and what is it’s value?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It looks to me as if it’s how the browser creates a function for the event handler when it’s specified as an HTML “onclick” attribute. I think what that does is:
<a>tag), an empty object (?), and the document object appear to be available symbols for the code in that function.That is,
this[0]is the<a>element itself,this[1]looks like an empty Object instance, andthis[2]is the document object. What this means is that in code you write as part of an “onfoo” event handler attribute (and not code in any ordinary event handler bound from straight JavaScript code), it’s possible to refer to the properties of the target element (the element for which you’re setting the attribute) and the properties of the document element as if they were present in the scope chain.If you change the code a little:
then you get the value of the “baseURI” property of the
<a>element. No need to prefix “baseURI” with anything that explicitly refers to the DOM node for the<a>element; it’s just “there” as if it were declared withvarin some enclosing scope.(checking w3c specs now …) edit — I haven’t found anything that stipulates what symbols are supposed to be available to the script code in event handlers. This is really weird.
edit again — Firefox seems to do the same thing, though I don’t see the explicit
withstatements anywhere.