class 10–205
- Describe one thing you’re learning in class today. Why do you think it will be important in your future web development journey?
Today in class we went into more detail into building classes with constructors and multiple methods. Classes are a great way to build libraries of something using javascript so i think they are a very interesting and useful tool.
- Can you offer a use case for the new arrow => function syntax?
the new arrow function syntax is just a quicker way to write functions for developers.
- How does this new syntax differ from the older function signature, function nameFunc(){}, both in style and functionality?
Arrow functions do not have their own this, the value of this remains the same
- Explain the differences on the usage of foo between function foo() {} and const foo = function() {}
function foo() {} is a function declaration, const foo = function () {} is a function expression.
- What advantage is there for using the arrow syntax for a method in a constructor?
Because arrow functions dont work well with this, I would not use them in a constructor. Generally i have found myself leaning towards arrow functions because theyre the newer and more efficient and clean way to write a function but this seems to be the one drawback.
- Can you give an example for destructuring an object or an array?Destructuring helps to unpack data from objects.
Example:
const car = {
make: ‘honda’,
model: ‘accord’,
year: ‘2015’
}
const {make, model} = movie
console.log(make, model); // ‘honda’, ‘accord’
- Explain Closure in your own words. How do you think you can use it? Don’t forget to read more blogs and videos about this subject.
Closure gives you access to an outer functions scope from an inner function.