示例:
Array A = [1,2,3,4];
此数组传递给一个函数。在该函数中定义新数组并编写一个代码,将数组A的内容复制到新数组中两次,因此新数组将如下所示。
newArray = [1,2,3,4,1,2,3,4].
谢谢。
答案 0 :(得分:1)
您可以使用<div class="fixed-background">
<h1>Fixed Background</h1>
</div>
<div class="fixed-placeholder"></div>
<div class="bottom-container">
<h2>More content down here</h2>
</div>
Array.prototype.concat()
答案 1 :(得分:0)
我建议使用%iframe{ frameborder: "0", height: "500", scrolling: "no", src: "/pdfjs/web/viewer.html?file=#{file}", style: "border: 0", width: "100%", webkitallowfullscreen: "", mozallowfullscreen: "", allowfullscreen: "" }
回答。但是如果你想将它乘以两倍以上,并且你正在寻找替代解决方案,你也可以这样做,
guest271314
答案 2 :(得分:0)
首先,你的语法不对。请参阅以下代码,该代码来自MDN
var vegetables = ['parsnip', 'potato'];
var moreVegs = ['celery', 'beetroot'];
// Merge the second array into the first one
// Equivalent to vegetables.push('celery', 'beetroot');
Array.prototype.push.apply(vegetables, moreVegs);
console.log(vegetables); // ['parsnip', 'potato', 'celery', 'beetroot']
在你的情况下。你可以这样做。
var A = [1,2,3,4];
Array.prototype.push.apply(A, A);
var A = [1,2,3,4];
Array.prototype.push.apply(A, A);
console.log(A);
在发布基本问题之前开始参加教程。以下教程网站可以帮助您获得基本的JS。
https://developer.mozilla.org/en-US/docs/Web/JavaScript http://www.tutorialspoint.com/javascript/
答案 3 :(得分:0)
默认数组&#39; arr = [1,2,3,4,5]&#39;这将被复制到&#39; newarr&#39;通过功能&#39; arrcopy()&#39;
var arr=[1,2,3,4,5];
var newarray=[],na=[];
function arrcopy(na){
for(var i=0;i<2;i++){
for(var j=0;j<na.length;j++){
newarray[(i*na.length)+j]=na[j];
}
}
alert(newarray);
}
arrcopy(arr);
注意:只有内置函数才有更简单的方法...