关于 js中圆括号 ()

 

var fun1 = function() {return 'hello fun1'} ();

image

var fun2 = (function() {return 'hello fun2'}) ();

image

 

如果直接

function() {return 'hello fun1'} (); 报错,函数没有被括起来,产生了歧义认为 {}有可能是json对象,固有语法错误.

image

(function() {return 'hello fun2'}) ();   //正确语法,定义且执行一个函数

image

 

string to json 参见:http://www.cnblogs.com/leamiko/archive/2011/05/07/2039780.html

posted @ 2011-09-09 10:06  leamiko  阅读(930)  评论(0编辑  收藏  举报
document.getElementById('MySignature') && document.getElementById('MySignature').style.display = "none"; document.getElementById('MySignature') && document.getElementById('blog_post_info').style.display = "none";