He can, but then you call d3.format(".2f")every time, not once. Depending on what the function does and how often it is called, this may add extra overhead.
With the IIEF (immediately called function expression) returning a closure, you "cache" fmtfor all future uses percent.
source
share