I am getting format like this in an array here is my array=
var array= [{"address":"Jaipur"},{"address":"Mumbai"},{"address":"Mumbai"}]
I want format like this
var array= [
"Jaipur",
"Mumbai"
];
what things should be done to in JSON so i can get desired array.
You can use Set to get unique values, and spread it into an array again.
var array= [{"address":"Jaipur"},{"address":"Mumbai"},{"address":"Mumbai"}];
var res = [...new Set(array.map(x => x.address))];
console.log(res)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With