re: Syntactical Overkill in JavaScript VIEW POST


Nice article!

Quick tip: In your pre-ES2015 callApi() example, token and type would have to be defined above the function call, to be equivalent to the first version.
Otherwise they exist only inside your callback. ;)


var token
var type

callApi(function(response) {
  token = response.token;
  type = response.type;

The thing is that you can't use token and type in the body of the caller of callApi bc you don't know if the callback was called and it's side-effects were produced.

Code of Conduct Report abuse