zoukankan      html  css  js  c++  java
  • js数组之可变函数

      在js的数组中有两个方法为数组添加元素:1.push();2.unshift(),push函数是将元素添加到数组的末尾,现在不用说大家估计也能猜出来,unshift这个函数就是把元素添加到数组的开头的位置上。

      上代码:

              

    <html>
    <head>
    	<title>数组的字符串表示</title>
    	<script type="text/javascript">
    	
    
    
    	function B(){
    		var names1=["zhangsan1","lisi1","wangwu1"];
    		names1.push("lily1");
    		names1.unshift("lily2");
    		
    		alert(names1);
    
    	}
    
    	</script>
    </head>
    <body>
    <input type="text" name="name" id="name">
    <input type="button" value="dian" onclick="B();">
    
    </body>
    </html>
    

      

  • 相关阅读:
    string的sizeof
    计算程序运行时间
    sleep所在头文件
    Mysql复制表结构、表数据
    UIView属性
    UITextView
    UITextField属性
    UISwitch属性
    UISlide属性
    UISegment属性
  • 原文地址:https://www.cnblogs.com/airycode/p/4819810.html
Copyright © 2011-2022 走看看