No history yet

Introduction to JavaScript

The Language of the Web

If you've ever interacted with a website—clicked a button that revealed more content, watched an animated chart, or filled out a form that gave you instant feedback—you've seen JavaScript in action. It's the programming language that brings web pages to life.

Think of it this way: HTML provides the basic structure of a webpage, like the skeleton of a body. CSS adds styling, like the skin and clothes. JavaScript is the nervous system and muscles that allow for movement and interaction.

Without JavaScript, the web would be a collection of static documents. With it, we get dynamic, responsive applications that feel more like software than simple pages. It runs directly in your web browser, which means you don't need any special software to see it work.

Setting Up Your Workspace

To start writing JavaScript, you don't need much. Your code is just plain text, so you could technically use any text editor. However, a specialized code editor makes the process much easier. These tools offer features like syntax highlighting, which colors your code to make it more readable, and auto-completion to help you write faster.

Lesson image

Some popular free code editors include Visual Studio Code, Atom, and Sublime Text. For this course, any of them will work perfectly. The key is to have a dedicated place to write and save your .js files.

Your First Playground The Console

Every modern web browser comes with a built-in tool called the developer console. It's a fantastic place to test small snippets of JavaScript code without having to create a file. Think of it as a scratchpad for experimenting.

You can open the console in most browsers by right-clicking anywhere on a webpage and selecting "Inspect" or "Inspect Element," then clicking on the "Console" tab. On a Mac, the shortcut is often Option + Command + J. On Windows, it's Control + Shift + J.

Once it's open, you'll see a command prompt, usually marked with a > symbol. You can type JavaScript directly into it and press Enter to run it. Let's try it. Type the following line into your console and press Enter.

console.log("Hello, world!");

The console will immediately display the text "Hello, world!" back to you. The console.log() command is a fundamental tool for developers to print information and see what's happening inside their code. You can also use the console as a calculator. Try typing:

100 + (50 * 2)

It will instantly return the answer, 200. The console is your direct line to the browser's JavaScript engine. It's an essential tool for learning, debugging, and testing ideas quickly.

Quiz Questions 1/5

What is the primary role of JavaScript in web development?

Quiz Questions 2/5

Which of the following is a specialized tool specifically designed for writing and editing code?

Now that you have your tools set up and know how to use the console, you're ready to start writing real JavaScript.