Array value problem

var value = [{"value": {"year": 2018, "month":3, "count": 123}},{"value": {"year": 2018, "month":12, "count": 68}}];//
var value = [ {"year": 2018, "month":3, "count": 123},{"year": 2018, "month":12, "count": 68}]//

Feb.02,2022

var result = value.map(x => x.value);

use map function

> var value = [{'value': {'year': 2018, 'month':3, 'count': 123}},{'value': {'year': 2018, 'month':12, 'count': 68}}];
undefined
> value.map(v=> v.value)
[ { year: 2018, month: 3, count: 123 },
  { year: 2018, month: 12, count: 68 } ]
>

var value = [{'value': {'year': 2018, 'month':3, 'count': 123}},{'value': {'year': 2018, 'month':12, 'count': 68}}];
var valueResult = value.map((item)=>{
    return item.value
});
:valueResult =[ {'year': 2018, 'month':3, 'count': 123},{'year': 2018, 'month':12, 'count': 68}]

for loop to construct new objects; it's easier to use Map directly.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1ea5ad7-47b3c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1ea5ad7-47b3c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?