Day 1: Introduction, Variables & Data Types
Day 1: The Language of the Web
Welcome to the JavaScript Fundamentals Series. Over the next 10 days, we will transform you from a complete beginner into a capable web developer.
What is JavaScript?
JavaScript (JS) is the programming language that makes websites interactive.
- HTML is the structure (the skeleton).
- CSS is the style (the clothes).
- JavaScript is the logic (the brain/muscles).
Setting Up
You donโt need to install anything to start! every web browser has a JavaScript engine built-in.
However, for this course, we recommend using VS Code and Node.js environment, or simply right-click in your browser > Inspect > Console.
Variables: Storing Data
In modern JavaScript (ES6+), we use let and const. Avoid the old var.
1. let (Changeable)
Use let when you expect the value to change later.
let score = 0;
score = 10; // Totally fine
console.log(score); // Output: 10
2. const (Constant)
Use const for values that should never be reassigned. This is the default choice for 90% of your code.
const pi = 3.14;
// pi = 3.15; // Error! Assignment to constant variable.
Data Types
JavaScript has a few basic types:
- String: Text.
"Hello World"or'JavaScipt'. - Number: Integers and decimals.
42,3.14. - Boolean: True or False.
true,false. - Null: Intentionally empty.
null. - Undefined: Variable declared but not assigned.
undefined.
const name = "Jack"; // String
let age = 30; // Number
let isStudent = false; // Boolean
let emptyValue = null; // Null
let notAssigned; // Undefined
Template Literals
The modern way to combine strings and variables using backticks (`).
const name = "Alice";
const greeting = `Hello, ${name}! Welcome to the course.`;
console.log(greeting);
// Output: Hello, Alice! Welcome to the course.
Homework for Day 1:
- Open your browser console (F12).
- Create a constant for your birth year.
- Create a variable for the current year.
- Calculate your age and log it using a template literal:
"I am X years old".
See you in Day 2 for Control Flow!