const x = [{
"hour": 0,
"total_count": 0,
"male_count": 0,
"female_count": 0
}, {
"hour": 1,
"total_count": 0,
"male_count": 0,
"female_count": 0
}, {
"hour": 2,
"total_count": 0,
"male_count": 0,
"female_count": 0
}, {
"hour": 3,
"total_count": 0,
"male_count": 0,
"female_count": 0
}, {
"hour": 4,
"total_count": 0,
"male_count": 0,
"female_count": 0
}, {
"hour": 5,
"total_count": 0,
"male_count": 0,
"female_count": 0
}, {
"hour": 6,
"total_count": 0,
"male_count": 0,
"female_count": 0
}, {
"hour": 7,
"total_count": 1,
"male_count": 0,
"female_count": 1
}, {
"hour": 8,
"total_count": 21,
"male_count": 3,
"female_count": 18
}, {
"hour": 9,
"total_count": 230,
"male_count": 110,
"female_count": 120
}, {
"hour": 10,
"total_count": 308,
"male_count": 151,
"female_count": 157
}, {
"hour": 11,
"total_count": 238,
"male_count": 103,
"female_count": 135
}, {
"hour": 12,
"total_count": 236,
"male_count": 128,
"female_count": 108
}, {
"hour": 13,
"total_count": 237,
"male_count": 153,
"female_count": 84
}, {
"hour": 14,
"total_count": 234,
"male_count": 130,
"female_count": 104
}, {
"hour": 15,
"total_count": 180,
"male_count": 99,
"female_count": 81
}, {
"hour": 16,
"total_count": 203,
"male_count": 117,
"female_count": 86
}, {
"hour": 17,
"total_count": 235,
"male_count": 139,
"female_count": 96
}, {
"hour": 18,
"total_count": 194,
"male_count": 111,
"female_count": 83
}, {
"hour": 19,
"total_count": 149,
"male_count": 89,
"female_count": 60
}, {
"hour": 20,
"total_count": 38,
"male_count": 20,
"female_count": 18
}, {
"hour": 21,
"total_count": 1,
"male_count": 1,
"female_count": 0
}, {
"hour": 22,
"total_count": 1,
"male_count": 1,
"female_count": 0
}, {
"hour": 23,
"total_count": 0,
"male_count": 0,
"female_count": 0
}]
const r = x.filter(obj => (obj.hour <= 10 || obj.hour >= 22))
console.log(r)
はあなたがマップに何を期待していない状態で、アレイを再構築するのは簡単?より良い選択肢にフィルタをかけることができますか? –
あなたのデータには、「cosnt x」の誤字があります。 – Nisarg
あなたのフィドルをチェックしてください。 'const x'にする必要があります – Sinto