If you have latest command-line SpiderMonkey or my little tool
'SyntaxJS' (see https://github.com/ariya/syntaxjs for the code), you
can see the syntax tree produced by the parser.

For the case:

  function foo(x) { alert(x); }(1);

the output looks like:

    {
        "type": "Program",
        "body": [{
            "type": "FunctionDeclaration",
            "id": "foo",
            "params": [{
                "type": "Identifier",
                "name": "x"
            }],
            "body": {
                "type": "BlockStatement",
                "body": [{
                    "type": "ExpressionStatement",
                    "expression": {
                        "type": "CallExpression",
                        "callee": {
                            "type": "Identifier",
                            "name": "alert"
                        },
                        "arguments": [{
                            "type": "Identifier",
                            "name": "x"
                        }]
                    }
                }]
            }
        },
        {
            "type": "ExpressionStatement",
            "expression": {
                "type": "Literal",
                "value": "1"
            }
        }]
    }


Just my 2 cents to the otherwise excellent explanation in this thread.



-- 
Ariya Hidayat
http://www.linkedin.com/in/ariyahidayat

-- 
To view archived discussions from the original JSMentors Mailman list: 
http://www.mail-archive.com/[email protected]/

To search via a non-Google archive, visit here: 
http://www.mail-archive.com/[email protected]/

To unsubscribe from this group, send email to
[email protected]

Reply via email to