Welcome, everyone! Before we dive into learning JavaScript, we need to set up our development environment. We'll be using Visual Studio Code (VS Code) as our code editor. Follow these steps to get everything ready:
- Open your web browser and go to the Visual Studio Code website.
- Click on the big blue button that says "Download for Windows". This will start downloading the installer.
- Once the download is complete, locate the downloaded file (it should be named something like
VSCodeSetup-x.x.x.exe
wherex.x.x
is the version number). - Double-click the file to start the installation process.
- You’ll see a setup wizard. Click "Next" to proceed through the steps.
- Accept the license agreement and click "Next".
- Choose the destination folder (the default location is usually fine) and click "Next".
- When you reach the "Select Additional Tasks" step, make sure to check the following options:
- "Create a desktop icon"
- "Add to PATH" (this is very important for running VS Code from the command line)
- Click "Next" and then "Install". The installation process will take a few moments.
- Once the installation is complete, make sure the option "Launch Visual Studio Code" is checked and click "Finish". VS Code will open.
- If it doesn’t open automatically, you can start it from the desktop icon or search for "Visual Studio Code" in the Start menu.
- When VS Code opens, you’ll see a welcome page. On the left sidebar, click on the Extensions icon (it looks like a square with four squares inside).
- In the search bar at the top of the sidebar, type "JavaScript (ES6) code snippets". Click "Install" on the first result by charalampos karypidis.
- Next, search for "Live Server" and install it. This extension allows you to launch a local development server with live reload feature for static & dynamic pages.
- Optionally, you can install "Prettier - Code formatter" to help format your code.
To run JavaScript outside the browser, we need Node.js.
- Open your web browser and go to the Node.js website.
- Click on the green button that says "LTS". This stands for Long Term Support and is the recommended version for most users.
- Once the download is complete, locate the downloaded file and double-click it to start the installation.
- Follow the installation steps. Make sure to check the box that says "Add to PATH" during installation.
- After installation, open a command prompt by pressing
Win + R
, typecmd
, and press Enter. - In the command prompt, type
node -v
and press Enter. You should see the version number of Node.js, which confirms it's installed correctly. - Also, type
npm -v
to check if npm (Node Package Manager) is installed. It should show a version number.
-
In VS Code, click on
File
>Open Folder...
. -
Select a location on your computer where you want to save your projects (e.g.,
C:\Users\YourSystemName\Documents\jstoreact
). Click "Select Folder". -
Now, click on
File
>New File
. Name the fileindex.html
and press Enter. -
Inside
index.html
, type the following basic HTML structure:<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>My First JavaScript Project</title> </head> <body> <h1>Hello, JavaScript!</h1> <script src="script.js"></script> </body> </html>
-
Now, create another new file in the same folder and name it
script.js
. -
Inside
script.js
, type the following code:console.log('Hello, JavaScript!');
-
Save both files.
- In the VS Code sidebar, right-click on
index.html
and selectOpen with Live Server
. This will open your HTML file in your default web browser. - Open the Developer Tools in your browser (you can do this by right-clicking on the page and selecting "Inspect" or pressing
Ctrl + Shift + I
). - Go to the
Console
tab in Developer Tools. You should see the messageHello, JavaScript!
printed there.
Congratulations! You have successfully set up your development environment and run your first JavaScript code. Now, you’re ready to start coding!
Now that we have our environment set up, let’s move on to learning the basics of JavaScript! We'll cover the following topics in this session:
- Overview of JavaScript
- Basic Syntax and Constructs
- Variables, Data Types, and Operators
Let's get started! If you have any questions during the setup or any step isn't clear, feel free to ask for help.