January 2020
Intermediate to advanced
470 pages
11h 13m
English
This style of continuous chained operation is also used in fluent APIs or interfaces. To give just one example, the graphic D3.js library (see https://d3js.org/ for more on it) frequently uses this style. The following example, taken from https://bl.ocks.org/mbostock/4063269, shows it in action:
var node = svg .selectAll(".node") .data(pack(root).leaves()) .enter() .append("g") .attr("class", "node") .attr("transform", function(d) { return "translate(" + d.x + "," + d.y + ")"; });
Each method works on the previous object and provides access to a new object that future method calls will be applied to (such as the selectAll() or append() methods) or updates the current one (like the attr() attribute setting calls ...
Read now
Unlock full access