Back to questions
JuniorTheoryCommon
What happens when the program runs?
console.log("a");
console.log(b);
console.log("c");a, then ReferenceError
- Expecting only
ReferenceError: that is how aSyntaxErrorbehaves. An unknown name is found only when its line runs, so line 1 has already printeda. - Expecting
undefinedand thenc: a name the program does not have is an error, not an empty value, and the error stops the program, so line 3 never runs.
- What changes if line 2 has a typo such as
console.log(b;instead? - What would you add to the program so that line 2 prints a value?