April 2018
Beginner to intermediate
406 pages
9h 33m
English
This is the last piece that you'll need to understand, as it tends to appear in a lot of JavaScript code tied to Phoenix channels. This last concept is centered around destructuring variables and arguments and it actually works a lot like what you're used to in Elixir. It basically allows you to do things like this:
const person = { firstName: "Jane", lastName: "Smith", age: 30};const { firstName, lastName, age } = person;console.log(firstName); // Will output "Jane"console.log(lastName); // Will output "Smith"console.log(age); // Will output "30"
This is a nice, cleaner way of doing something that previously required as much code as this:
const person = { firstName: "Jane", lastName: "Smith", age: 30