1

I'd would like to better understand javascript arrow functions as being used in the below d3 code. I've read some tuts on the topic but a translation of the below code would help me better understand how it is used in this particular case. What is the equivalent of this code in ES5?

d3.csv('data/harry_potter.csv').then(res => {
    console.log('Local csv', res);
});
Jack Bashford
  • 43,180
  • 11
  • 50
  • 79
jesse
  • 133
  • 1
  • 9
  • 1
    You can try Babel's transpiler online [here](https://babeljs.io/repl#?babili=false&browsers=&build=&builtIns=false&spec=false&loose=false&code_lz=CYZgdAxgzgbgFAcmAQwC7IPQAtkCdcCeA-gA4D2qqAprpLAgJRipZUB2cuVUABALwA-HgG8AUDwk8IZNlDIAbKmHlkA5ogAyZCMnlT6AGh5coDANyiAvuaA&debug=false&forceAllTransforms=false&shippedProposals=false&circleciRepo=&evaluate=false&fileSize=false&timeTravel=false&sourceType=module&lineWrap=true&presets=es2015%2Creact%2Cstage-2&prettier=false&targets=&version=7.5.5&externalPlugins=) to see es6 to es5 conversion and vice-versa, and also much more. – makkBit Jul 21 '19 at 07:26

1 Answers1

0

Nothing funny is happening with the lexical this binding, and there's no implicit return, so it's really simple:

d3.csv("data/harry_potter.csv").then(function(res) {
    console.log("Local csv", res);
});
Jack Bashford
  • 43,180
  • 11
  • 50
  • 79