by pornel · 11y ago · 0 comments
.attr('transform', function(d) { return "translate(" + (d.x + 1) + " 0)"; })
becomes: .attr('transform', d => `translate(${d.x + 1} 0)`)
And: .attr({x:x, y:y, width:width, height:height})
.attr({x, y, width, height})In context, we were commenting on this:
.attr('transform', d => `translate(${d.x + 1} 0)`)
which looks pretty similar to the coffeescript counterpart: .attr 'transform', (d) -> "translate(#{d.x + 1} 0)"
Five subtle differences, but it shows how the things that are new/different about ES6 are more similar to typescript and coffeescript than ES5.Careful though: Libraries like jQuery and D3 can and/or do rebind `this` and that can be a gotcha in both TypeScript and straight ES6. You can end up having to mix both declaration styles, which is gross.