(),用于表达中,用来改变表达式的优先级。例如:
(a+b)*c;
var f = function(){}
var f = ( function(){} )
return ( function(){} ) //定义匿名函数,并返回
( function(){} ) () //定义匿名函数,并调用
{},用于定义方法,定义方法块,直接定义对象。例如:
{//定义方法块, i变量在方法块之外可以访问
var i = 1;
alert(i+1);
alert(i+2);
alert(i+3);
alert(i+4);
}
alert(i+5);
var a = {pa:"1",pb:"2"}; //直接定义对象。此对象的类是匿名的,使用也就不能访问类相关的属性,例如prototype
[],定义数组。例如
var buffAr = [
'<div id="',
'', //index 1, DIV ID attribute
'" style="position:absolute;top:',
'', //index 3, DIV top position
'px;left:',
'', //index 5, DIV left position
'px;width:',
'', //index 7, DIV width
'px;height:',
'', //index 9, DIV height
'px;overflow:hidden;/"><img src=/"',
'', //index 11, IMG URL
'/" width=/"',
'', //index 13, IMG width
'/" height=/"',
'', //index 15, IMG height
'/" alt=/"',
'', //index 17, IMG alt text
'/"><//div>'
];
JavaScript中(),{},[]的使用
最新推荐文章于 2023-03-25 11:59:25 发布