JavaScript中(),{},[]的使用

(),用于表达中,用来改变表达式的优先级。例如:
      (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>'
   ];

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值