Day 1: What is JavaScript & The Console
Daily Objective
Section titled “Daily Objective”Understand where JavaScript runs (browser engines like V8 and Node.js), connect a script to HTML, and execute code using the browser console.
1. Where Does JavaScript Run?
Section titled “1. Where Does JavaScript Run?”JavaScript is an interpreted, high-level, multi-paradigm programming language. Initially created for web browsers, it now runs on servers via runtime environments like Node.js.
2. Linking a Script to HTML
Section titled “2. Linking a Script to HTML”Always link scripts right before the closing </body> tag or use the defer attribute in the <head>:
<!-- In index.html --><!DOCTYPE html><html lang="en"> <head> <meta charset="UTF-8" /> <title>JS Fundamentals</title> </head> <body> <h1>JavaScript in Action</h1> <script src="script.js"></script> </body></html>3. The Developer Console
Section titled “3. The Developer Console”In script.js:
console.log('Hello, JavaScript!');console.info('Helpful information');console.warn('This is a warning');console.error('This is an error message');Open Chrome DevTools (F12 or Ctrl + Shift + I) and view the Console tab.
Daily Hands-on Practice (70%)
Section titled “Daily Hands-on Practice (70%)”- Create
index.htmlandscript.jsin a new folder and open with Live Server. - Log mathematical expressions like
console.log(25 * 4)and string combinations. - Open Node.js in your terminal by typing
nodeand evaluate basic expressions.