一、arguments  实参参数的数组
        实参【实际的值】,形参【形式上的参数】

        当参数个数不固定的时候使用。
        示例:
script>
var getSub=function(){
var re=0;
for(var i=0;i<arguments.length;i++){
re+=arguments[i];
}
return re;
}
alert(getSub(1,2,3,4,5,6));//21 </script>

二、批量设置样式

  1. .cssText='width:100px;height:50px';//缺点:会覆盖之前样式
  2. 有缺陷
with(obj.style){
样式名=样式值;
width=width;(无法设置该属性)
}

  3、自定义方法

<script>
function setStyle(obj,json){
for(var name in json){
obj.style[name]=json[name];
}
}
window.onload=function(){
var oDiv=document.getElementById('box');
oDiv.onclick=function(){
setStyle(oDiv,{'width':'200px','height':'300px'});
}
}
</script>

  4、字符串常用方法

var str='abd3333';
str.charAt(0); 【获取某一位置的字符】//结果:a
str.indexOf('b');【查找某个字符串的位置,找到返回位置,否则 返回-1】//结果:1,找不到返回-1
str.lastIndexOf('3')【从后往前找】;//结果:6
str.substring(开始位置,结束位置(不包括结束位置));【截取字符串,前包括后不包括】
str.substring(开始位置):【从开始位置截取到最后】
str.toUpperCase();//转换为大写
str.toLowerCase();//转换为小写
str.split('特定的字符');//如果写了一个空字符,每个字符都被分出来。否则按照指定字符进行分割。
str.repalce('',function(){})
str.match(); 匹配出来是数组。

  5、字符串比较

字符串数字比较:‘2’>'12'   true    '156'>'9'.false,比较的是第一个字符,完事后就不往后面比较了。
字符串中文:‘你’>'我',乱来。
字符串大小写字母:‘A’>'a',false

  6、数组常用方法

arr.push();//从后面加,返回被添加后的数组的长度。
arr.pop();//从后面干掉,返回被删掉的东西。
arr.shift();//从前面删除,返回被删掉的东西。
arr.unshift();//从前面加
arr.splice(开始的位置,长度);//删除,返回删除的东西,返回了arr
arr.splice(开始的位置,0,要插入的东西)//插入
arr.splice(开始的位置,长度,要替换的东西)//替换(先删除后插入)
arr.join(分隔符);//数组转换成字符串
arr3=arr1.concat(arr2);//数组合并
arr.reverse();//数组反转 welcome to zhinengshe ====>zhinengshe to welcome
arr.sort();//数组排序。
arr.sort(function(num1,num2){
if(num1>num2){
return 1;
}else if(num1<num2){
return -1;
}else{
return 0;
}
})//解决数字排序问题9】
arr.sort(fucntion(num1,num2){return num1-num2});//从小到大简写
arr.sort(fucntion(num1,num2){return num2-num21});//从大到小简写
arr.map(function(val,index,context){return val+1 });//遍历数组,修改数组中每一项,返回新数组,不修改原数组
arr.forEach(function(val,index,context){});//遍历数组,没有返回值,不修改原数组
arr.filter(function(val,index,context){});//筛选数组,返回符合条件的新数组,不修改原数组

  

  

最新文章

  1. Android开发-之监听button点击事件
  2. Codeforces Round #383 (Div. 2) D. Arpa&#39;s weak amphitheater and Mehrdad&#39;s valuable Hoses(分组背包+dsu)
  3. Android test---CTS
  4. spring3 的restful API RequestMapping介绍
  5. 在MySql 5.0 的表里同时添加两个自动更新的timestamp字段
  6. 乐视云计算基于OpenStack的IaaS实践
  7. boost之thread
  8. lambda形式(转)
  9. cocos2d-x lua与c++简单交互
  10. iOS-Reachability的使用
  11. 简单的GDI+双缓冲的分析与实现
  12. Condition-线程通信更高效的方式
  13. AfxMessageBox和MessageBox差别
  14. python下使用protobuf
  15. iOS应用开发详解
  16. react-native 打包apk
  17. Repository 简化实现多条件查询
  18. Verilog TestBench Coding Style
  19. 前端jquery学习--03
  20. The transaction associated with this command is not the connection&#39;s active transaction

热门文章

  1. php数组倒叙支持多维数组
  2. [LeetCode 题解]: Validate Binary Search Tree
  3. java 添加到数据库的数据没有时分秒
  4. [VSTO] warning CS0467 解决方案
  5. C#串口数据互通小程序
  6. c#设计模式之:外观模式(Facade)
  7. 工作流2013 assign to问题
  8. Mysql表操作《一》表的增删改查
  9. TOMCAT在POST方法提交参数丢失问题
  10. file.delete()的优化