1 - Getting started

Chapter 1: Getting Started with JavaScript

What is JavaScript?

  • JavaScript: A high-level programming language for adding interactivity to web pages.

  • Core Technologies: Part of the web trio—HTML, CSS, and JavaScript.

  • Use Cases:

    • Adding behaviors to websites (e.g., form validation).

    • Creating animations.

    • Updating data without refreshing the page.

    • Used in browsers, servers, and mobile apps.

Setting Up the Development Environment

Tools You Need

  • Text Editor/IDE: Choose any of the following:

    • Visual Studio Code: Popular, full of extensions for JS development.

    • Sublime Text: Fast and simple.

    • Atom: Open-source, lots of plugins.

  • Web Browser: Modern browsers like Google Chrome, Firefox, or Edge have built-in developer tools:

    • Developer Tools: Access via F12 or right-click → "Inspect". Useful for debugging JS.

  • Node.js: To run JavaScript outside the browser.

    • Download: From nodejs.org.

    • Check Installation: Run node -v in terminal to verify.

  • Git for Version Control:

    • Git: Install from git-scm.com.

    • GitHub: Use to host and share your projects.

Writing Your First JavaScript Program

  1. Create a New HTML File

    • Name it index.html.

    • Write this code:

  2. Explanation

    • HTML Structure: Basic page setup.

    • JavaScript: Embedded using <script> tag.

    • Console Output: console.log() prints to the browser's console (open with F12).

Understanding JavaScript in Browsers and Node.js

Environments Where JavaScript Runs

  • Browsers

    • JavaScript runs in all modern browsers.

    • Developer Tools:

      • Press F12 to open.

      • Use for debugging, inspecting elements, and testing JS code.

  • Node.js

    • Server-Side JavaScript: Allows JS to run on the server.

    • Built-In Modules: For handling files, HTTP, etc.

    • Check Installation: Run:

      • If it displays a version, Node.js is installed.

Summary

  • JavaScript is crucial for interactive web content.

  • Set up with Text Editor, Web Browser, Node.js, and Git.

  • You wrote your first JavaScript using console.log().

  • JavaScript runs in both Browser and Node.js environments.


Next Chapter: JavaScript Basics

Last updated