Every programming language has a grammar. In JavaScript, these rules are called syntax, and they define exactly how your instructions should be written to be understood by the browser.
1Statements & Semicolons
A JavaScript program is a sequence of statements. Each statement is a single instruction. While JavaScript has 'Automatic Semicolon Insertion', relying on it can lead to subtle bugs. Explicitly ending your statements with a semicolon (;) is a core best practice that ensures your logic is interpreted exactly as intended across all environments.
2The Identity Protocol
Identifiers are the names you choose for your code elements.
- →Case Sensitivity:
Useranduserare different. - →Start Rules: Must start with a letter,
$, or_. - →Reserved Words: You cannot use keywords like
class,return, orletas names. Following these rules is the first step toward writing error-free JavaScript.
