Sorry for the weird title, but I'm not sure what these functions are called:
options: {
someTrait: function(d) { return doSomething(d, outerScopeArray[i]); }
}
At first I thought they were anonymous functions but it's somehow expecting the first variable to be something. What this is called would be useful for me to look up more about it.
The problem I'm having though is that I want this function to access a variable in the outer scope. (outerScopeArray[i]) It's currently always undefined.
EDIT: this is how it's actually being called
testDurations[i] // data here is accessible, this section is repeated multiple times in a loop
$(newGraph).lineChart({
options: {
tickFormat: function(d) {
//testDurations[i] here is undefined.
console.log("testing durations", testDurations[i], "--", 10*60000)
if (testDurations[i] <= 10*60000){
return d3.time.format('%H:%M:%S')(new Date(d));
}
else{
return d3.time.format('%H:%M')(new Date(d));
}
},
});