Javascript jQuery上的分号
下面的jQuery在函数后面使用分号或不使用分号。为什么?Javascript jQuery上的分号,javascript,jquery,Javascript,Jquery,下面的jQuery在函数后面使用分号或不使用分号。为什么? jQuery(document).ready(function(){ jQuery("#red").treeview({ animated: "fast", collapsed: true, control: "#treecontrol", persist: "cookie" }) }); 它适用于所有浏览器。这不会导致错误吗?JavaScript实际上不需要分号。那只是惯例 我建议使用分号,就像我
jQuery(document).ready(function(){
jQuery("#red").treeview({
animated: "fast",
collapsed: true,
control: "#treecontrol",
persist: "cookie"
})
});
它适用于所有浏览器。这不会导致错误吗?JavaScript实际上不需要分号。那只是惯例
我建议使用分号,就像我建议缩进代码一样。为什么要这样做?分号是可选的(至少在这个位置)。