Mission to Mars

Welcome to my blog post from the fifth week intermediate Javascript class!

Apr 30 · 2 min read

Describe one thing you’re learning in class today.

We learned how to manipulate objects and classes for our marsMission project. We also learned how to turn a code plan into functioning code.

Can you offer a use case for the new arrow => function syntax? How does this new syntax differ from other functions?

Arrow functions remove the need for the “return” keyword. They are a shorter, more efficient way to write functions. However, they are less readable than standard functions, so they are not the best choice when working on teams or if someone needs to review your code.

Explain the differences on the usage of foo between function foo() {} and var foo = function() {}

The first example of the keyword “foo” is the name of a function. The latter example is the name of a variable.

Can you give an example of destructuring an object or an array?

Destructuring assignment allows you to assign the properties of an array or object to variables.

Without destructuring assignment, you might access the first three items in an array like this:

var first = someArray[0];
var second = someArray[1];
var third = someArray[2];

With destructuring assignment, the equivalent code becomes more concise and readable:

var [first, second, third] = someArray;

Source: https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/

What advantage is there for using the arrow syntax for a method in a constructor?

As far as I can tell, there is no advantage because arrow fucntions cannot be constructors.

Source: https://medium.com/tfogo/advantages-and-pitfalls-of-arrow-functions-a16f0835799e

Explain Closure.

Closure refers to the scope of a variable. Scope is the area available for a function to access variables.

Erin McBride

Written by

Hi there! Below is my weekly blog that I wrote while enrolled in Austin Coding Academy.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade