This is a portion of code from https://bl.ocks.org/mbostock/4183330
I am trying to understand how names.some(function(d)...})
works.
Shouldn't the anonymous function passed to
.some()
return a conditional statement that "countires" can be evaluated against?When will
names.some(..)
return true or false?Why doesn't
d.name = n.name
create "name" property in "countries" without "return"?
queue()
.defer(d3.json, "world-110m.json")
.defer(d3.tsv, "world-country-names.tsv")
.await(ready);
function ready(error, world, names) {
var countries = topojson.feature(world,world.objects.countries).features
countries = countries.filter(function(d) {
return names.some(function(n) {
if (d.id == n.id) return d.name = n.name;
});
})