0% found this document useful (0 votes)
1 views2 pages

JavaScript Basics

This document provides a quick revision of JavaScript basics, including comments, semicolons, using the browser console, and printing text. It explains the purpose of comments, the role of semicolons, and how to run code in the console. Additionally, it covers methods for printing multiple strings and styling text in the console.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views2 pages

JavaScript Basics

This document provides a quick revision of JavaScript basics, including comments, semicolons, using the browser console, and printing text. It explains the purpose of comments, the role of semicolons, and how to run code in the console. Additionally, it covers methods for printing multiple strings and styling text in the console.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

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!

You might also like