Debugging Flashcards

1
Q

What’s a breakpoint?

A

A point of code where the debugger will automatically pause the JavaScript execution. (only if debugger is open in chrome)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What’s it called when there is a point of code where the debugger will automatically pause the JavaScript execution. (only if debugger is open in chrome)

A

breakpoint

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What happens when a function declaration is made into a breakpoint?

A

You can’t make a function declaration a breakpoint. Function and variable declarations are done before the code is run through. They are not options to make breakpoints.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Create a conditional breakpoint

Can it use variables and functions of the js file?

A

Right click, edit breakpoint, create script

Yes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Write a statement direction in code that will pause the code.
How does it behave

A

debugger;
IF debugger is open in chrome, it will pause at that line. It becomes a sort of breakpoint but it cannot be paused or removed like breakpoints created in chrome.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

From code:
debugger;
let x;

What happens when you add:
- x
- console.log(‘apple’);
To the watch list

A

x will wait for the variable to be assigned. Return &ltnot available> then return undefined
With console.log(‘apple’) it can evaluate the expression from the beginning (and returns undefined)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How to watch a variable change as the code goes on

A

Watch an expression under Sources > Watch

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q
With code:
debugger;
let myArray = [1, 2, 3];
What happens when you add:
- myArray[1]
- myArray[6]
To the watch list
A

They both start as &ltnot available>
when the array is created,
- myArray[1] becomes 2
- myArray[6] becomes undefined

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q
What happens if you declare 2 values into the same variable:
let x = 123;
let x = 'apples';
And make each one a breaking point?
A

The code breaks before the debugger even starts.

Variable names are set aside (but not assigned) before the script starts

How well did you know this?
1
Not at all
2
3
4
5
Perfectly