In my javascript console surrounding a value with parenthesis doesn't change the output.
1
=> 1
(1)
=> 1
Same thing with a string variable:
x = "foo"
=> "foo"
x
=> "foo"
(x)
=> "foo"
Same thing with a function in a variable:
f = function(){}
=> function (){}
f
=> function (){}
(f)
=> function (){}
If I don't assign the function to a variable I get an error:
function(){}
=> Uncaught SyntaxError: Unexpected token ((…)
Surrounding the anonymous function with parenthesis and I get the expected result:
(function(){})
=> function (){}
Why is this?
Thanks for any insight.