Destructuring and Closure

Meredith Davis
1 min readMay 31, 2020

We are learning about classes vs. objects right now. Classes will be important because they make your code much shorter and clearer, which is something that I could always use more help on. I think it will help my project be much simpler when it comes time to start.🤓

We are also learning a couple of other JavaScript terms. Object destructuring is a way to extract values from an object and put them inside their own variables. You can also set default values inside the variable if the value isn’t defined in the object.

Array destructuring helps you extract values from an array, and you can also set default values in the new variable. However they are overridden if they are defined first in the array.

Closure basically means the scope of the variable and whether it is accessible within the function, outside the function or to other functions. It gives you access to an outer function’s scope from an inner function. This is critical when whiteboarding, so you need to take into account where you need to call your variables before determining where they are accessible.

--

--

Meredith Davis
0 Followers

Former Kindergarten Teacher, now a student at Austin Code Academy learning Front Stack Web Development