Day 23 JavaScript Debugging & Coding Etiquette

Finally, see the note-taking end in sight! Tomorrow will finally be done with writing down notes from w3schools on JavaScript. Today I covered 4 sections in w3schools which were debugging, style guide, best practices, and mistakes.

For JavaScript debugging I did not know that every browser had a native debugger. This topic wasn’t gone into detail as I thought it would be. I guess I’ll learn more hands-on when I go back to freecodecamp courses. What was explained in the section on debugging was to use console.log() method to see values. Another method with using console.log to debug is to use break points. At each break point, JavaScript will stop executing, and let you examine JavaScript values.

JavaScript style guide, best practices, and mistakes can be all packaged into one. These were mainly about coding etiquette and to have your code be readable. Coding etiquette covered things from how variable names, object names, and statement rules should typically be written. Also to use spaces after each operator (=+-*/).

Best practices went into keeping the code short for faster execution. Also to avoid global variables,  avoid new,  avoid  ==,  avoid eval(). Declare all variables to go to the top, which was gone into depth with strict mode. However, never declare number, string, or Boolean objects.

The performance section had some good tips in there. It was literally about JavaScript performance like how to execute loops faster. Statements or assignments that can be placed outside the loop will make the loop run faster. Putting your scripts at the bottom of the page body lets the browser load the page first.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Up ↑

%d bloggers like this: