# Week 3 - Destructuring, Async, Cordova Camera

# Destructuring

A new feature that was added with ES6 was destructuring, which is a way that we can extract properties or values from Objects or Arrays. Typically this is done when passing a variable to a function. If that variable is an object that has a dozen properties but we only want one or two then we can use destructuring to quickly grab those two properties with one line of code.

Learn more about Destructuring

# Rest and Spread

The rest and spread operators allow us to extract a range of values from an array or to assign a range of values from an array to a list of variables, again with only one line of code.

Learn more about Rest and Spread Operators

# Async Await

When you call an asynchronous method like fetch, loading an image, timers, getting geolocation, talking to a database or reading a file, then we need to handle this in our code. Most asynchronous tasks have a callback method that we can use. Another approach we can use is wrapping the task inside a Promise and then using a then().

If you want to use the Promise version but want to simplify your code then we can use the keywords async and await.

Learn about async-await

# Merges Folder

Cordova lets you keep the bulk of your code for your project in one CSS file and one JS file. However, there will be times where you need to do something differently depending on whether it is an Android App or an iOS app.

We can use the merges folder to achieve this.

# Cordova Camera Plugin

To be able to access the mobile device camera to take pictures or videos and then use the pictures or videos on a web page inside a Cordova app, we need to use the cordova-plugin-camera plugin.

Learn how to use the Camera plugin

TODO

  • Read the content and watch the videos for Weeks 3 and 4
Last Updated: 1/28/2021, 6:25:43 PM