Skip to content

Instantly share code, notes, and snippets.

@cpietsch
Created August 19, 2015 19:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cpietsch/851b4497568b12523f1d to your computer and use it in GitHub Desktop.
Save cpietsch/851b4497568b12523f1d to your computer and use it in GitHub Desktop.
var elements = data.map(function(d){
return new nmap_element({
id:d.id,
x:d.x,
y:d.y,
weight:d.weight ? d.weight : 1),
klass:d.class ? d.class : 1)
});
});
// anstatt
var elements = [];
for(var i = 0; i<data.length; i++){
elements.push(new nmap_element({
id:data[i].id,
x:data[i].x,
y:data[i].y,
weight:(("weight" in data[i]) ? data[i].weight : 1),
klass:(("class" in data[i]) ? data[i].class : 1)
}));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment