Two ways for deleting exiting elements

Two ways for deleting exiting elements
0

#1

pen: [ https://codepen.io/ustvarno/pen/WxdPbk ]

i saw first method here for deleting exiting elements that works for me, (with adding new data and then remove other (existing) )

line:bar.selectAll(".negative").data([]).exit().remove()

but here this way doesn’t work from d3 docs,

line: text.exit().remove();

why this happens? i know why first works, but i saw second one not just at that link i provided