دنبال کننده ها

۱۳۹۶ مهر ۱۲, چهارشنبه

javascript - Push entire subarray

[ad_1]



I have an array this the format below. Trying to push an entire subarray to a new array and keep the array format. Have no success with the code below.



Array:



"#VER": 
"A-1":
"verdatum": "2016-07-08",
"vertext": "1073, Almi",
"trans": [
"account": "1510",
"amount": "52500.00"
,
"account": "3010",
"amount": "-42000.00"
,
"account": "2611",
"amount": "-10500.00"
]
,
"A-2":
"verdatum": "2016-07-08",
"vertext": "1074, Text",
"trans": [
"account": "1510",
"amount": "15000.00"
,
"account": "3010",
"amount": "-12000.00"
,
"account": "2611",
"amount": "-3000.00"
]
,
"A-3":
"verdatum": "2016-07-08",
"vertext": "1075, Villa",
"trans": [
"account": "1510",
"amount": "17250.00"
,
"account": "3010",
"amount": "-10800.00"
,
"account": "2611",
"amount": "-3450.00"
,
"account": "3010",
"amount": "-3000.00"
]





Want to push the following subarray



"A-2":
"verdatum": "2016-07-08",
"vertext": "1074, Text",
"trans": [
"account": "1510",
"amount": "15000.00"
,
"account": "3010",
"amount": "-12000.00"
,
"account": "2611",
"amount": "-3000.00"
]



Code so far, but changes format of array



var newarray = [];
$.each(array["#VER"], function(i, item)
if (i === "A-2")
newarray.push(i,item);

);



[ad_2]

لینک منبع