lodash.js fiddle
Added lodash from cdnjs.com in order to have lodash capabilities in chrome.
by Gabriel Correa
HTML
<script src="//cdnjs.cloudflare.com/ajax/libs/lodash.js/1.2.1/lodash.min.js"></script>
JavaScript
var array = [{
"Nome": [
"Calciumnull"
]
},
{
"Peso": [
"999null"
]
},
{
"Raça": [
"Dellorian",
"Prometheus"
]
},
{
"Horario de nascimento": {
"_id": "62bdee805cad80135c16e5bd",
"value": "09:33"
}
},
{
"Dia de nascimento": {
"_id": "62bdc77b5cad80135c02f53e",
"value": "09/06/2022"
}
},
{
"Estagio de vida": [
"Jovem"
]
}
];
function customPush(obj, path, item) {
if (_.has(obj, path)) {
let arr = _.get(obj, path);
arr.push(item)
} else {
_.set(obj, path, [item]);
}
}
filteredArray = array;
console.log(filteredArray)