猿问

Javascript代码的小小疑问(82)——将b对象对象插入a对象

/*
*带有序列号的对象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?序号接着
繁花不似锦
浏览 499回答 4
4回答

largeQ

var globle= {}; Globle.nodges=[]; globle.edges=[]; 结果就是 globle={nodges:[],              edges:[]}   {"nodges":[],"edges":[]}这种形式的其实叫json对象 JSON.parse(globle)就转成这种对象了    

qq_花开花谢_0

<!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>  

繁花如伊

 你这是什么玩意对象?var a = {{aa:1}},这语法都不正确了。如果是数组的话,直接concat就是了。
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答