Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix/ATC-108 #112

Merged
merged 1 commit into from
Nov 17, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -988,7 +988,9 @@ export default class AircraftFlightManagementSystem {
return null;
}

return `${this.following.star}.${window.airportController.airport_get().icao}`;
const { icao } = window.airportController.airport_get();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't seen this notation before. Purely for my own reference, what is the difference between this and simply const icao =?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am very glad you asked!

This is an ES6 feature called Destructuring. These two examples are effectively the same thing:

const icao = window.airportController.airport_get().icao
const { icao } = window.airportController.airport_get();

Destructuring also works with several vars:

const { icao, name, radio } = window.airportController.airport_get();

In this example you end up with three constants icao, name, radio that are references to those same properties in the AirportModel.

Its a way to set a const with a name you are expecting to be returned.

Does that make sense?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERY NEAT!

And yes. I thought the ... operator was what destructuring was with expanding arrays?


return `${this.following.star}.${icao.toUpperCase()}`;
}

/**
Expand Down