w1coding.comAll tutorials

JavaScript Introduction

JavaScript lessons
  1. Environment Setup
  2. Introduction
  3. Enviroment
  4. Basics
  5. Variables
  6. Operators
  7. Condition
  8. Functions
  9. Arrays
  10. Bjects
  11. DOM
  12. Objects
  13. Colors
  14. DOM
  15. Events
  16. Validation
  17. JSON
  18. Error
  19. Callbacks
  20. Promises
  21. Fetch
  22. Local
  23. Modules
  24. Animation
  25. Classes
  26. Iframes
  27. Responsive

Introduction to JavaScript

Welcome to JavaScript! JavaScript is a versatile programming language that helps developers add interactive features to websites. It can be used for simple tasks like showing alerts to creating full-featured applications.

What is JavaScript?

JavaScript was created in 1995 and has since become the most widely-used programming language for web development. Along with HTML and CSS, JavaScript forms the "holy trinity" of the web, allowing you to create rich, interactive websites.

Why Use JavaScript?

  • Interactive Content: JavaScript makes your pages interactive and responsive to user actions.
  • Dynamic Updates: JavaScript allows you to change content dynamically without refreshing the page.
  • Extensive Ecosystem: Libraries and frameworks like React, Angular, and Vue are built using JavaScript.

Example: Hello, World!

To start, let’s write a simple program that prints “Hello, World!” to the console.

      
        <script>
          console.log("Hello, World!");
        </script>
      
    

Open your browser’s console to see the message. You can open the console by pressing F12 or Ctrl+Shift+J on most browsers.

Activity

Try It Yourself!

Add the following code to your HTML file to display "Hello, World!" in the console:

        
          <!DOCTYPE html>
          <html>
          <head>
            <title>Hello World Example</title>
          </head>
          <body>
            <script>
              console.log("Hello, World!");
            </script>
          </body>
          </html>
        
      

Save the file and open it in a browser. Check the console to see the message!

Quiz

Quick Quiz

  1. What is JavaScript primarily used for?
  2. What are the three main components of the web?
  3. How can you open the console in your browser?

Answers: JavaScript adds interactivity; HTML, CSS, and JavaScript; F12 or Ctrl+Shift+J.