
JavaScript: Syntax, Statements, Comments & Variables
1. JavaScript Syntax Syntax is simply the set of rules that define how JavaScript code must be written just like grammar rules in English. JavaScript is case-sensitive. This means name , Name , and NAME are all treated as different things. let name = " Karthick " ; // ✅ valid let Name = " Ravi " ; // also valid, but different variable Whitespace (spaces, tabs, blank lines) is mostly ignored by JavaScript, but using it properly makes your code readable. // Hard to read let x = 5 ; let y = 10 ; let z = x + y ; // Easy to read let x = 5 ; let y = 10 ; let z = x + y ; 2. JavaScript Statements A statement is a single instruction that tells JavaScript to do something. Think of it like a sentence in English — it expresses a complete action. let age = 25 ; // declares a variable console . log ( age ); // prints the value to the console alert ( " Hello, World! " ); // shows a popup in the browser Semicolons Statements usually end with a semicolon ; . While JavaScript can often figure out where
Continue reading on Dev.to Webdev
Opens in a new tab

