Debugging Flashcards
What are the Chrome and Firefox Javascript consoles also known as?
DevTools
What are DevTools used for?
To debug Javascript code.
What’s considered the most helpful debugging tool?
How is it best used?
console.log()
Placing it at strategic points in your code can show you the intermediate values of variables. It’s good practice to have an idea of what the output should be before looking at what it is. Having check points to see the status of your calculations throughout your code will help narrow down where the problem is.
What’s the output of the code below?
In order, the console will display the strings string, number, object, and object.
Of the primitive types in Javascript, which ones are mutable?
Only the object type is mutable.
(In Javascript, arrays are a type of object).
List the 8 most common syntax errors?
- Spelling
- Unclosed brackets, braces, parethesis and quotes
- Mixing single and double quotes
- Using asignment operator instead of equality operator
- Missing open and closing parethesis after a function call
- Arguments passed in the wrong order when calling a function
- Off-by-one error(OBOE) when using indexing
- Reinitialising(or not) variables inside loops
What are the “falsy” values?
Which values are not “falsy”?
false, 0, null, “”, undefined and NaN.
All other values on their own resolve to true in Javascript.
What are two common causes of infinite loops?
One error is incrementing or decrementing a counter variable in the wrong direction from the terminal condition. Another one is accidentally resetting a counter or index variable within the loop code, instead of incrementing or decrementing it.