JavaScript Basics – Quick Revision Notes
1. Comments
• // → single-line comment
• /* ... */ → multi-line comment
• Browser completely ignores comments
• Uses of comments:
o Explain what code does
o Ask questions / leave notes
o Mark // TODO tasks
o Temporarily disable code (debugging / testing)
2. Semicolons ;
• Act like period (.) in English → end of a statement
• JavaScript has ASI (Automatic Semicolon Insertion) → browser adds ; automatically in most
cases
• → Semicolons are now mostly optional
• Still many developers write them for clarity & safety (style choice)
3. Browser Console (Quick Coding Playground)
• Open: Right-click → Inspect → Console tab (Chrome/Firefox)
• Press Enter → run the code
• Press Shift + Enter → new line (without running) → good for multi-line code
4. First Code – Hello, World
JavaScript
[Link]("Hello, World");
5. Styling Text in Console
JavaScript
[Link]("%cHello, World", "color: blue; font-size: 40px;");
• %c → tells console that next argument contains CSS styles
• Styles written as normal CSS rules (in string)
6. Printing Multiple Words / Strings
Method A – Concatenation (+)
JavaScript
[Link]("Hello " + "there, " + "World");
// Output: Hello there, World
Method B – Multiple arguments (comma separated)
JavaScript
[Link]("Hello", "there,", "World");
// Output: Hello there, World
// → automatically adds space between arguments
Quick Comparison
• + → joins into one single string
• , → keeps values separate, console adds spaces
Good luck with your Front-end journey!