用推()之后,数组被记录为一个数字 [英] After using push(), array is logged as a number
问题描述
我试图得到一些图像阵列来翻阅。第一组必须按降序排列,而第二组必须按升序排列,所以我写了这个:
I'm trying to get an array of some images to flip through. The first set need to be in descending order, while the second set need to be in ascending order, so I have written this:
var flipArray = [];
function createFlipArray(older, newer){
flipArray = $("#"+older).children();
flipArray = flipArray.get().reverse();
flipArray = flipArray.push($('#'+newer).children());
console.log(flipArray);
loopThroughImages();
}
当我按第二套到第一组,它记录了数组4,即使有全阵列式6项。
When I push the second set onto the first set, it logs the array as 4, even though there are 6 items in the whole array.
如果我登录阵列后,我的大孩子,将它返回的HTML对象,我希望看到我后,就推新的孩子。
If I log the array after I populate it with the older children, it returns with HTML objects, which I expect to see after I push the newer children on.
有什么建议?
推荐答案
Array.prototype.push
返回该数组的新长度。它的修改的原始数组。删除 flipArray =
之前。
Array.prototype.push
returns the array's new length. It modifies the original array. Remove the flipArray =
before it.
这篇关于用推()之后,数组被记录为一个数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!