/*
*带有序列号的对象a,b
*
*/
var a = {
{
nIndex: 0,
name: "sdfhdrt",
type: "B",
len: 24
},{
nIndex: 1,
name: "fgdfg",
type: "B",
len: 24
},{
nIndex: 2,
name: "fgdfg",
type: "B",
len: 24
},{
nIndex: 3,
name: "fgdfg",
type: "B",
len: 24
},{
nIndex: 4,
name: "fgdfg",
type: "B",
len: 24
},{
nIndex: 5,
name: "fgdfg",
type: "B",
len: 24
},{
nIndex: 6,
name: "fgdfg",
type: "B",
len: 24
},{
nIndex: 7,
name: "fgdfg",
type: "B",
len: 24
}
}
var b ={
{
nIndex: 8,
name: "fgdfg",
type: "C",
len: 12
},{
nIndex: 9,
name: "fgdfg",
type: "C",
len: 12
},{
nIndex: 10,
name: "fgdfg",
type: "C",
len: 12
},{
nIndex: 11,
name: "fgdfg",
type: "C",
len: 12
}
}
//如何用JS将b添进a?序号接着
4 回答
largeQ
TA贡献2039条经验 获得超7个赞
var globle= {};
Globle.nodges=[];
globle.edges=[];
结果就是
globle={nodges:[],
edges:[]}
{"nodges":[],"edges":[]}这种形式的其实叫json对象
JSON.parse(globle)就转成这种对象了
qq_花开花谢_0
TA贡献1835条经验 获得超7个赞
<!DOCTYPE html> <html> <body> <p id="demo">合并数组。</p> <button onclick="myFunction()">click me</button> <script> function myFunction() { //你可以把对象转换为数组 var hege = ["Cecilie", "Lone"]; var stale = ["Emil", "Tobias", "Linus"]; var children = hege.concat(stale); var x=document.getElementById("demo"); x.innerHTML=children;
//把数组再转换为对象 } </script> </body> </html>
添加回答
举报
0/150
提交
取消