Describe one thing you’re learning in class today.
We are learning all about the different types of loops. The “classical” loops such as
while are pretty straight forward while the newer
for…of loops are a bit more challenging to wrap your head around. Loops take a block of code and repeat it over and over until you tell it to stop. The
for loop repeats a block of code a specific number of times and is most commonly used to iterate over arrays and strings. The
while loop repeats a block of code while a specific condition is true. The newer versions are
for…of and their primary benefit is to save space and make your code easier to read.
"use strict";? What are the advantages and disadvantages to using it?
Strict mode is declared with the string
“use strict”; at the beginning of your JS file. It is basically stating that all of your JS should be read literally and any “sloppy” errors are made very obvious that may be hidden otherwise. Generally, it helps with testing and running efficient code but could also make everything break if you aren’t careful.
Explain the importance of standards and standards bodies like ECMA.
Standards are important because it makes code useable across multiple platforms. If standards bodies such as ECMA didn’t officially release standards, then the creators of browsers would each have their own idea of what they should support and it would take much longer to adopt new features. This system allows for new features to be adopted regularly and for your code to be (hopefully) useable across different browsers.
What actions have you personally taken on recent projects to increase the maintainability of your code?
I’ve been aiming to utilize variable names that make sense rather than random ones such as x. I’ve also been trying to add in comments where I may find them helpful. Another useful technique is going in and cleaning up any extra code that I may have tried and commented out in the process of building a new project. One way to do a similar thing is to use git branches to try new things and then either merge to the main branch or just copy/paste to the new branch.
Why is it, in general, a good idea to leave the global scope of a website as-is and never touch it?
When variables are declared in the global scope it can be more difficult to tell where they are coming from within a function for instance. It can also cause problems with variable names clashing when declared globally.