Second week of JavaScript — at home learning is taking a toll on me
The second week of our intro to JavaScript was fairly difficult. Due to the pandemic, being forced to learn something I find challenging on an online platform has been more difficult that I expected; but, I have managed to still make it through and learn how to execute the code necessary to complete my exercises for the week.
Describe one thing you’re learning in class today. | (Class was Wednesday, May 6) I lead the white-boarding session today in creating the classic “fizzbuzz,” function. Although I was able to create one using a for loop fairly quickly, I was taught how to skip through numerical values to only the ones I need using the third statement of the for loop. This executes the code much faster because it does not have check every number — just the ones with particular values.
What is "use strict";
? What are the advantages and disadvantages to using it? | This is put at the beginning of the JavaScript page to declare strict mode. The purpose of declaring this is to make sure that one writes more secure JS by tightening restrictions on how it is written. It catches mistakes and disables features that are not well thought out. However, it will throw errors if variables have not been declared, and as it is a “more recent” addition to JS it can break old code.
Explain function hoisting in JavaScript. | If one has declared variables inside a function, no matter where they appear within the function they are “hoisted,” to the top. The same applies to global variables. This means that no matter where it appears, for example, inside a function, the definition of the variable still applies anywhere within it.
Explain the importance of standards and standards bodies like ECMA. | Standardizing code is important for developers in the same way having rules in any language is important — if there is no standard for how a language is spoken, others can’t understand it. It is important not only for web developers to be able to write the language, but to read and understand the language as well. Often times developers work in teams, and if those standards were not in place and there was too much flexibility, they would not be able to work together and understand each other’s work.
What actions have you personally taken on recent projects to increase maintainability of your code? | I have recently learned how to create my own unit tests to make sure my code is working how I want it to.
Why is it, in general, a good idea to leave the global scope of a website as-is and never touch it? | Declaring global variables in JavaScript can be bad because it will default all variables to the global scope unless declared elsewhere.