如何将元素存储在数组中并在之后使用它?

问题描述 投票:1回答:1

[如果我们要保存一个字符串,我使用“ push”并将其存储在数组中,这样我就可以在“ for”或“ if”中使用它,但是它像下面这样保存:

Object{
device_id: "234567890"
flow_id: "098765432"
manifest_href: "http://google.com"
};
var Extract_manifest_href = [];
Extract_manifest_href.push(element.manifest_href);

我的结果像波纹管一样:

Array(0) []
browser_prototype.js:240
length:1
0:"http://google.com"

我看到的Array的长度为“ 0”,但是其中有一个元素,并且当我想使用它并写道:console.log(manifest_href[0]);没有给我Array的内容!为什么当我们推一个字符串时,数组的长度为0!并例如这样设置:

Array(1) = ["http://google.com"] // give like above Array(0) 
javascript arrays object push
1个回答
0
投票
console.log(Extract_manifest_href[0]);
© www.soinside.com 2019 - 2024. All rights reserved.