STICK TO THE (Java)SCRIPT

Omar Gonzalez
3 min readSep 9, 2020

When things in life seem like they are not going as planned the best advice that can be presented is to “stick to the script”. Hell, this is good advice for various activities and milestones in life. When things are spiraling out of control, we must remember to stick to the script and do the best that you can! In my case the script would be in reference to the JavaScript (lol) There was a time during this course where I was certain I was ready to accept a job at Google as a lead developer. Don’t worry the last couple of weeks have humbled me something serious and I am back to Earth where I belong. Even though there was times where it felt like I was hanging on for dear life I put my head down and continued to follow the plan that I laid out for myself at the beginning of the course in June. I have adjusted to life of class from home and I am actually going to be sad when things go back to normal.

1. Describe one thing you’re learning in class today. Why do you think it will be important in your future web development journey?

This week we were learning about classes and how they relate to everyday life. My favorite example was when we were working on a bank account assignment, and we made a class that would initiate the creation of a new bank account. We also built a seperate class that would deal with the transactions of the account. We also did some classes relating to cars. I think this is important to me because when I am playing a game I can see what the developer probably did to incorporate the small details into the game. such as a health bar or even how much gas is in a car.

2. Can you offer a use case for the new arrow => function syntax?

I actually prefer to use the “fat arrow” function syntax. An example of a function that adds two numbers while using the syntax mentioned above would be let addTwoNumbers = (num1, num2) => {

let solution = num1 + num2;

return solution;

}

A. How does this new syntax differ from the older function signature, function nameFunc(){}, both in style and functionality?

As far as functionality to my understanding there is not a difference and is just a matter of personal choice. As far as the syntax goes I like to believe the fat arrow method looks a little more professional, while the older method is more clear that the following is a FUNCTION

B. Explain the differences on the usage of foo between function foo() {} and const foo = function() {}

The first example is a function named foo, while the second is a variable called foo that is equal to a function. In terms of functionality they are the exact same!

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

There is no advantage or disadvantage to using either syntax.

3. Can you give an example for destructuring an object or an array?

“The destructuring assignment syntax is a JavaScript expression that makes it possible to unpack values from arrays, or properties from objects, into distinct variables.” — MDN

4. 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.

A closure is the combination of a function bundled together (enclosed) with references to its surrounding state (the lexical environment). In other words, a closure gives you access to an outer function’s scope from an inner function. In JavaScript, closures are created every time a function is created, at function creation time.

--

--