0
我有對象的嵌套陣列的陣列,其中我需要格式化屬性中的每個對象映射整數數組對象
const myMap = {
'1':
[ { date: '2016-03-10T00:00:00', location: 'NV' },
{ date: '2016-03-10T00:00:00', location: 'WV' },
{ date: '2016-03-10T00:00:00', location: 'CA' } ],
'2':
[ { date: '2016-03-10T00:00:00', location: 'NJ' },
{ date: '2016-03-10T00:00:00', location: 'PA' } ],
'3':
[ { date: '2016-03-10T00:00:00', location: 'WA' },
{ date: '2016-03-10T00:00:00', location: 'NH' },
{ date: '2016-03-10T00:00:00', location: 'CA' } ]
}
我目前使用lodash和moment.js
有這樣的代碼var _ = require('lodash')
var moment = require('moment')
_.map(myMap["date"], (a) => { moment(a).format('DD MMM YYYY') })
console.log(myMap)
// []
它目前返回一個空數組,我將如何格式化每個日期而不改變格式?