This is functional code:
// A
d3.select("body").selectAll(".testDiv")
.data(["div1", "div2", "div3"])
.enter().append("div")
.classed("testDiv", true)
.text(function(d) { return d; });
The next snippet is essentially the same, except that instead of using "div" as an argument for append, a function(d) is used to simply return "div":
// B
d3.select("body").selectAll(".testDiv")
.data(["div1", "div2", "div3"])
.enter().append(function(d) { return "div"; })
.classed("testDiv", true)
.text(function(d) { return d; });
However, B does not function properly and results in the error message "Uncaught TypeError: Failed to execute 'appendChild' on 'Node': parameter 1 is not of type 'Node'."
What is the difference between using "div" as an argument for append() versus function(d) { return "div"; }
?