$(function() {
var locations = [{
country: 'china',
id: 1
}, {
country: 'india',
id: 2
}, {
country: 'USA',
id: 3
}, {
country: 'india',
id: 4
}, ]
//获取所有区域
var location = [];
var temp1 = {};
for (var i of locations) {
if (!temp1[i.country]) {
location.push(i.country)
temp1[i.country] = true
}
}
console.log(location); // ['china', 'india', 'USA']
})