Max Schmeling

Javascript Destructuring

Basic example

function sendMessage({ text }) {
  console.log(`Sending message: ${text}`);
}

Advanced example

const action = {
  type: 'CodePush/DOWNLOAD_PROGRESS',
  payload: {
    progress: .55
  }
};

const { type } = action;
console.log(type); // CodePush/DOWNLOAD_PROGRESS