Destructuring

Arrays and objects.

Pull names out of arrays and objects in one line.

Goal

Log city and units from a row.

const [first, second] = ["Nairobi", "Mombasa", "Kisumu"];
console.log(first, second);
const row = { city: "Kisumu", units: 5 };
const { city, units } = row;
console.log(city, units);
const row = { city: "Eldoret", units: 3, price: 40 };
const { city, ...rest } = row;
console.log(city);
console.log(rest);
function label({ city, units }) {
  return city + ": " + units;
}
console.log(label({ city: "Nakuru", units: 4 }));