1/32
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No analytics yet
Send a link to your students to track their progress
Errors
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
syntax
The “grammar” in the programming language is the _____, a set of rules that defines the structure of the instructions
keywords
while the “vocabulary” are the ___ or list of words that can be used to build instructions
Correct Message:
After leaving the mall, turn right into the second path, and drive 600 m. Wait on the spot.
Syntax Error: missing period
This error violates the language syntax rule, as a declarative sentence should end with a period.
Semantic Error: pth
This new word is not recognizable in the vocabulary of the natural language, thus creating an error. It can also be a word that is out of context, such as using “male” instead of “mall”.
Logical Error: left
It is an error as it is not what was originally the intended direction compared to the original message. This error is not easily detectable by the compiler.
SyntaxError
appears when a code is ill-formed, just like the sample above, when typos occur, or when unmatching parenthesis or brackets. The code cannot even be executed as JavaScript cannot understand it.
iff (true) {
console.log("true");
}
Error message: //-> Uncaught SyntaxError: Unexpected token '{'
ReferenceError
in JavaScript, as the compiler does not know its meaning. This error occurs when the programmer tries to access a function or a variable that does not exist
let a = 3;
let a = c;
Error mesage: //-> Uncaught ReferenceError: c is not defined
TypeError
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.
const someConstValue = 4;
someConstValue = 3;
Error message: // -> Uncaught TypeError: Assignment to constant variable
let someNumber = 12;
someNumber.length();
Error message: // -> Uncaught TypeError: someNumber.length is not a function
RangeError
This error is generated when a value is passed to a function outside its acceptable range
let testArray1 = Array(10);
console.log(testArray1.length);
// -> 10
let testArray2 = Array(-1);
console.log(testArray2.length);
Error message: // -> Uncaught RangeError: Invalid array length
throws
it generates and ___ specific objects with information about the encountered error. In syntax errors, the JavaScript engine does not allow the program to run and uses the console to show the error message.
run-time errors, or exceptions
other errors, which appear while the program is running.
console.log('123');
conole.log('456');
console.log('890');
The word conole has caused a ReferenceError, which stops the program from working after the first line.
Exception handling, or error handling
is done to prevent the program from stopping in such a situation.
finally Statement
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. 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.
Debugging
is part of troubleshooting in programming.
Step-by-Step Program Execution
Resume
Step Into
Step Over
Step Out
Resume
resumes the execution of the script typically. The debugger runs the program and “breaks” on user-defined breakpoints
Step Into
treats the function as a set of instructions intended to be executed separately. It is used when the code needs to be analyzed in detail. The debugger will jump inside the code of the next instruction if it is a function call.
Step Over
is used when the next instruction is a call to a function where the impact is unclear or uninterested. It treats the function call as something indivisible
Step Out
allows to immediately jump out of a function where the code is paused. This action proceeds until the function returns if the debugger is within the code block