Debugging and Error Handling Flashcards

1
Q

8 types of errors

A

Error: runtime error
ReferenceError
SyntaxError
TypeError - invalid type, can’t be used there
EvalError - when using eval()
InternalError - represents an internal error in the JS engine; for e.g. excessive recursion
RangeError - numeric variable outside of its valid range
URIError - error when encoding or decoding an invalid URI

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

console API

A

contains several methods to aid in debugging

console. log()
console. error()
console. info()

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

debugger statement

A

can be used in code to set a breakpoint

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

additional console methods

A

console. warn() - writes a warning
console. table() - writes an object as a table
console. group() - creates a new inline group, which indents the output by an additional level
console. groupEnd() - exits the current inline group
console. assert() - writes an error messages if the specified expression is false
console. trace() - writes a stack trace to the console
console. time() - starts a timer
console. timeLog() - logs the value of the specified timer
console. timeEnd() - method ends a timer

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

types of breakpoints

A

line-of-code: allows pausing code execution before a specific line of code; it can also be conditional

DOM change: pauses code execution on the code that changes a DOM node or its children

XHR / Fetch: pauses code execution when the request URL of an EXR contains a certain string

Event Listener: pauses on the event listener that runs after a specific event is executed

exception: pauses on the line of code that throws a caught or uncaught exception
function: pause code execution when a specific function is called

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

setTimeout()

A

non blocking

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

3 valid states of promises

A

pending, fulfilled, rejected

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

promise methods

A

Promise.all - accepts an array or promises and returns a new promise; it is resolved when all the specified promises are resolved

Promise.allSettled - static method accepts an array of promises and returns the status and value/error for each promise

Promise.race - returns the first settled promise

Promise.any - when one of the promises is fulfilled, a single promise is returned

Promise.resolve - returns a new promise that resolves with the specified object

Promise.reject - returns a new promise that is rejected with the specified error

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

stack

A

call stack contains functions that are being processed in which each function is stacked as a frame. after being processed, the function is popped out the call stack

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

heap

A

objects that are created during runtime are allocated in a heap, which is a term used to describe a large region of memory in the running machine

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

queue

A

message queue or callback/event queue

where an async callback waits to be pushed by the event loop into the call stack for processing

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

specifying the events to monitor

A
monitorEvents
three ways of specifying the event or events to monitor for a given object
-event name
-array of events
-event type
How well did you know this?
1
Not at all
2
3
4
5
Perfectly