CS401A's Pre-Finals: Fundaments of Web Prog. Module 07 Flashcards
For pre-final and final exams. (30 cards)
in the operation of programs happen due to misconceptions when solving a problem, improper use and typos of the programming language, or the inability to predict user behavior.
Errors and Exceptions (OpenEDG, 2023)
Errors
Programming language communicates just like natural language in that it has its grammer and vocabulary. The “grammar” in the programming language is the
Errors and Exceptions (OpenEDG, 2023)
syntax,
a set of rules that defines the structure of the instructions,
Errors and Exceptions (OpenEDG, 2023)
syntax,
Programming language communicates just like natural language in that it has its grammer and vocabulary.
in the programming language
“vocabulary” are the
Errors and Exceptions (OpenEDG, 2023)
keywords
or list of words that can be used to build instructions.
Errors and Exceptions (OpenEDG, 2023)
keywords
Errors and Exceptions (OpenEDG, 2023)
appears when a code is ill-formed,
when typos occur, or when unmatching parenthesis or brackets. The code cannot even be executed as JavaScript cannot understand it.
SyntaxError
A SyntaxError
Errors and Exceptions (OpenEDG, 2023)
iff (true) { console.log("true"); }
\_\_\_\_\_\_
Error
(OpenEDG, 2023)
SyntaxError
Errors and Exceptions (OpenEDG, 2023)
The error occurs when the programmer tries to access a function or a variable that does not exist.
(OpenEDG, 2023)
ReferenceError
Errors and Exceptions (OpenEDG, 2023)
let a = 3; let a = c;
\_\_\_\_\_\_\_\_\_
Error
ReferenceError
Errors and Exceptions (OpenEDG, 2023)
This error occurs when a specific value is not of the expected type, such as changing the constant value or checking the length of a variable that is not a string.
TypeError
Errors and Exceptions (OpenEDG, 2023)
const someConstValue = 4; someConstValue = 3; let someNumber = 12; someNumber.length();
\_\_\_\_
Error
TypeError
Errors and Exceptions (OpenEDG, 2023)
This error is generated when a value is passed to a function outside its acceptable range.
RangeError
Errors and Exceptions (OpenEDG, 2023)
let testArray1 = Array(10); console.log(testArray1.length); let testArray2 = Array(-1); console.log(testArray2.length);
\_\_\_\_\_
Error
RangeError
Errors and Exceptions (OpenEDG, 2023)
When JavaScript detects syntactic or semantic errors, it generates and \_\_\_\_\_\_
specific objects with information about the encountered error.
throws
Errors and Exceptions (OpenEDG, 2023)
Other errors, however, are called \_\_\_\_\_\_\_\_
errors, or \_\_\_\_\_\_\_\_\_\_
, which appear while the program is running.
run-time
exceptions
Errors and Exceptions (OpenEDG, 2023)
is done to prevent the program from stopping in such a situation.
Exception handling, or error handling,
Errors and Exceptions (OpenEDG, 2023)
If an exception is thrown in the code block after the try
keyword, the program will not interrupt completely but instead jumps to the part of the code after the catch
keyword and continues from there.
Exception handling, or error handling,
Errors and Exceptions (OpenEDG, 2023)
Just like the catch
block, this is also an optional block of the try
statement, although at least one of them is required or a SyntaxError
is thrown.
finally
Statement
Errors and Exceptions (OpenEDG, 2023)
It can be used with or without the catch
block and is always executed after the try
and catch
blocks, no matter what errors are thrown.
finally
Statement
Errors and Exceptions (OpenEDG, 2023)
try { // code to try } finally { // this will always be executed }
This is the syntax for the
try.. finally
statement.
Errors and Exceptions (OpenEDG, 2023)
let a = 5; try { a = 10; } finally { console.log(a); } console.log(a);
The content of the finally block is executed, as the new value (\_\_
) is displayed instead of the initial declaration (\_\_
).
10
5
is part of troubleshooting in programming.
causes the program to stop or halt its execution on the line where it is placed and waits for a decision.
Debugging (OpenEDG, 2023)
Debugging
The debugger statement
console.log("Before debugger"); debugger; console.log("After debugger");
If debugging is present in a browser, the console in the developer tool will only show the \_\_\_\_\_\_ \_\_\_\_\_\_\_\_ \_\_\_
Debugging (OpenEDG, 2023)Before debugger
log
and display whether the code execution stopped, paused in the debugger, or is currently in debug mode.
It is a debugger feature to execute codes on a \_\_\_\_\_\_\_\_\_\_\_\_
basis.
Debugging (OpenEDG, 2023)
Step-by-Step Program Execution
step-by-step