javascript数组方法的使用
来源:互联网 发布:西安西工大科信软件 编辑:程序博客网 时间:2024/05/23 15:39
push方法在数组尾部添加数据,unshift方法在数组头部添加数据。
join使用方法为 a.join("任意字符");
a.reverse();
代码如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html><head><title>数组方法之增加和删除</title><style type="text/css">*{margin:0}#show{width:200px;height:200px;margin:0 auto;color:white;background:#2c2c2c;text-align:center}</style><script type="text/javascript">var a = [22,4,111,33];/*a.push("<span style='color:red'>a</span>");a.pop();a.unshift("<span style='color:yellow'>b</span>");*///a.reverse();document.write("<div id='show'>");document.write(a.concat("www")+"<br/>");//document.write(a.join("*")+"<br/>");document.write(a);document.write("</div>");</script></head><body></body></html>
代码如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html><head><title>数组方法</title><style type="text/css">*{margin:0}#show{width:200px;height:200px;margin:0 auto;color:white;background:#2c2c2c;text-align:center}</style><script type="text/javascript">//var a = [33,4,111,22];//a.slice(2);var a = [1,2,3,4,5,6,7,8,9];document.write("<div id='show'>");//document.write("结果为:"+a.slice(1,3)+"<br/>");document.write("结果为:"+a.splice(4,2,"a")+"<br/>");document.write(a.toString());document.write("</div>");</script></head><body></body></html>
0 0
- javascript 数组方法的使用
- javascript数组方法的使用
- javaScript array(数组)使用字符串作为数组下标的方法
- javascript数组基础和数组方法的各种使用
- JavaScript数组的方法
- javascript数组的方法
- javascript数组的方法
- javascript的数组方法
- javascript数组的方法
- JavaScript-数组的方法
- javascript 数组的使用
- Javascript数组的使用
- javascript数组的使用
- javascript数组的使用
- javaScript的数组使用
- javascript数组的使用
- javascript数组的定义及其属性和方法的使用
- JavaScript中的数组的join()方法的理解使用
- linux c学习笔记----UDP基础客户/服务编程(sendto,recvfrom)
- 告别烦人的cmd窗口——后台运行tomcat
- Android开发环境的搭建及HelloWorld
- 重要资料链接笔记
- java BigDecimal用法
- javascript数组方法的使用
- 小程序媛的迷茫 ----------- 功能和界面的分析
- Android - Activity和Context的区别
- UUID
- linux 命令—— source 详解
- Android - SQLite游标(Cursor)错误
- C++基础算法之 回文数
- freemarker 异常和错误显示
- Android程序员必备精品资源