Back to Developer Roadmap

Reference Vs Syntax Error

src/data/question-groups/javascript/content/reference-vs-syntax-error.md

4.0674 B
Original Source

A syntax error happens when you write code that the JavaScript engine can't understand, so your code won't run. It can be when you make a typo spelling a keyword or forget to close a bracket, parenthesis, or curly brace.

javascript
console.log("JavaScript interview questions"

A reference error occurs when you try to use a variable or a function that doesn't exist. The code will run, but it won't find what you're referencing since you didn't create the variable using let, var, and const keywords.

javascript
console.log(myStudy);