3js深入

可变参:arguments; 函数的参数组成的数组;

arguments[0],函数的第一个参数,arguments[1],第二个参数······;

result+=arguments[i];


oDiv.style.width只能获取行间样式;

如何获取非行间样式:

  //IE

  oDiv.currentStyle['width'];

  //chorom,FF

  getComputedStyle(oDiv,false)['width'];


函数:获取非行间样式

function getStyle(obj,name){
    if(obj.currentStyle){
       return oDiv.currentStyle[name];      
    }else{
        return getComputedStyle(obj,false)[name];
    }
}

函数 :设置,获取样式;

function setStyle(obj,name,value){
  if(arguments.length == 2){
        return obj.style[name]
    }else if(arguments.length == 3){
        obj.style[name]=value;
    }
}        

数组:定义:var a=[1、4、6];或者 var a = new Array(1、4、6);

arr.pop();从末尾删除

arr.push(4);从末尾添加4,是添加的数组元素;

arr.shift();从头删除;

arr.unshift(4);从头部添加,4是添加的元素;

a.concat(b);把数组a和数组b连接起来,a在前面;

arr.join('-');用‘-’把数组各元素连接起来,生产字符串;

arr.splice(起始位置,个数,元素);

    删除:splice(起点, 长度)
    //arr.splice(2, 3);

    //插入:splice(起点, 长度, 元素...);
    //arr.splice(2, 0, 'a', 'b', 'c');

    替换:arr.splice(2,2,'a','b');

原文地址:https://www.cnblogs.com/maoduoduo/p/3127179.html