最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

javascript數(shù)組克隆簡單實現(xiàn)方法

 更新時間:2015年12月16日 09:44:44   作者:hongweigg  
這篇文章主要介紹了javascript數(shù)組克隆簡單實現(xiàn)方法,實例分析了JavaScript中concat用于數(shù)組克隆的使用技巧,需要的朋友可以參考下

本文實例講述了javascript數(shù)組克隆簡單實現(xiàn)方法。分享給大家供大家參考,具體如下:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>新建網(wǎng)頁 1</title>
</head>
<body>
<script language=javascript>
var a = ['a','b','c','d','e','f'];
var b = a.concat();
b.push('test is ok!');
alert(b.join(','));
alert(a.join(','));
</script>
</body>
</html>

腳本之家小編補充

The JavaScript
To clone the contents of a given array, all you need to do is call slice, providing 0 as the first argument:

var clone = myArray.slice(0);

The code above creates clone of the original array; keep in mind that if objects exist in your array, the references are kept; i.e. the code above does not do a "deep" clone of the array contents. To add clone as a native method to arrays, you'd do something like this:

Array.prototype.clone = function() {
return this.slice(0);
};

And there you have it! Don't iterate over arrays to clone them if all you need is a naive clone!

希望本文所述對大家JavaScript程序設計有所幫助。

相關文章

  • JS訪問DOM節(jié)點方法詳解

    JS訪問DOM節(jié)點方法詳解

    這篇文章主要介紹了JS訪問DOM節(jié)點方法,結合實例形式較為詳細的分析了JS訪問DOM節(jié)點的相關函數(shù)與使用方法,需要的朋友可以參考下
    2016-11-11
  • javascript add event remove event

    javascript add event remove event

    javascript事件綁定和刪除功能代碼
    2008-04-04
  • 下載文件個別瀏覽器文件名亂碼解決辦法

    下載文件個別瀏覽器文件名亂碼解決辦法

    下載文件個別瀏覽器文件名亂碼解決辦法,需要的朋友可以參考一下
    2013-03-03
  • 最新評論

    汝阳县| 北票市| 仪征市| 龙门县| 永新县| 大同县| 台中县| 冀州市| 永新县| 舟曲县| 昌黎县| 镇沅| 高碑店市| 商南县| 图们市| 南阳市| 和顺县| 客服| 屏山县| 公安县| 讷河市| 苏尼特右旗| 庄河市| 乐都县| 收藏| 冷水江市| 仁怀市| 沙洋县| 普宁市| 疏勒县| 绥德县| 新沂市| 福贡县| 灌云县| 永嘉县| 东乌珠穆沁旗| 闽侯县| 板桥市| 怀远县| 平安县| 深泽县|