---Advertisement---

What is JavaScript? A Complete Introduction with Hello World Example Great 2025

By Manisha

Updated On:

---Advertisement---
What is JavaScript?

👉Tutorial-1: Java Script Array

🏹What is JavaScript?

What is JavaScript?: JavaScript is a powerful client-side scripting language used to create dynamic and interactive web pages. It enhances user experience by allowing developers to build interactive elements like forms, animations, and real-time updates. Additionally, JavaScript is widely used in game development and mobile app development.

  1. History of JavaScript
  2. How to Run JavaScript
  3. Tools You Need
  4. Writing Your First JavaScript Program
  5. JavaScript Variables and Assignments

🏹History of JavaScript

What is JavaScript?: JavaScript was created by Brendan Eich in 1995 and was first introduced in the Netscape browser. Initially, it was named LiveScript, but later renamed to JavaScript. Despite the similarity in names, JavaScript and Java are completely different programming languages. Java is a full-fledged programming language, while JavaScript is a lightweight scripting language primarily designed for web development.


🏹How to Run JavaScript

JavaScript is an interpreted language, which means it runs directly in a web browser. When an HTML page contains JavaScript, the browser reads and executes the script.

  • All modern web browsers support JavaScript, including Google Chrome, Mozilla Firefox, Microsoft Edge, and Safari.
  • It works on all operating systems, such as Windows, macOS, and Linux.
  • No additional software is required to run JavaScript—just a browser!

🏹Tools You Need

What is JavaScript?: To start coding in JavaScript, you need:

  1. A Text Editor: Popular choices include Visual Studio Code, Notepad++, Sublime Text, and Atom.
  2. A Web Browser: JavaScript runs in Google Chrome, Firefox, Edge, Safari, and other modern browsers.

🏹Writing Your First JavaScript Program

What is JavaScript?: JavaScript code is placed inside <script> tags within an HTML document. Let’s start with a simple “Hello World” example:

html

<!DOCTYPE html>

<html>

<head>

    <title>My First JavaScript Code</title>

    <script>

        alert(“Hello, World!”);

    </script>

</head>

<body>

</body>

</html>

  • The <script> tag encloses JavaScript code.
  • alert(“Hello, World!”); displays a pop-up message with “Hello, World!”.
  • When the page loads, the alert box will appear.

Note: In HTML5, specifying type=”text/javascript” in the <script> tag is optional.


🏹JavaScript Variables and Assignments

What is JavaScript?: Variables are used to store data values, such as numbers, strings, or expressions.

Declaring Variables in JavaScript

To declare a variable, use the var, let, or const keyword:

javascript

var name;   // Declaring a variable

let age;    // Declaring a variable (preferred in modern JavaScript)

const PI = 3.14; // Declaring a constant variable (value cannot be changed)

Assigning Values to Variables

You can assign values while declaring or later:

javascript

var name = “John”; // Declaration and initialization together

let age;

age = 25; // Assigning a value later

  1. Variable names must begin with a letter, underscore (_), or dollar sign ($).
  2. JavaScript is case-sensitive (studentName and studentname are different).
  3. Avoid using reserved keywords (e.g., var, function, return).

🏹JavaScript Example: Basic Arithmetic Operations

What is JavaScript?: Let’s see an example of how JavaScript handles arithmetic operations.

html

<!DOCTYPE html>

<html>

<head>

    <title>JavaScript Variables and Operations</title>

    <script>

        var num1 = 10;

        var num2 = 5;

        var sum = num1 + num2;

        var difference = num1 – num2;

        var product = num1 * num2;

        var quotient = num1 / num2;

        document.write(“First Number: ” + num1 + “<br>”);

        document.write(“Second Number: ” + num2 + “<br>”);

        document.write(“Sum: ” + sum + “<br>”);

        document.write(“Difference: ” + difference + “<br>”);

        document.write(“Product: ” + product + “<br>”);

        document.write(“Quotient: ” + quotient + “<br>”);

    </script>

</head>

<body>

</body>

</html>

  • var num1 = 10; var num2 = 5; declares two numeric variables.
  • We perform basic arithmetic operations (+, -, *, /).
  • document.write() outputs the results onto the web page.

🏹Conclusion

JavaScript is an essential web development language that allows developers to build interactive web pages. It runs on all browsers and operating systems, making it a versatile choice for developers.

✔ JavaScript was created by Brendan Eich in 1995.
✔ It runs inside a web browser and does not need any additional setup.
✔ JavaScript is case-sensitive and has three ways to declare variables: var, let, and const.
✔ You can use JavaScript to perform arithmetic operations and manipulate web pages dynamically.

Now that you know the basics, start experimenting with JavaScript to build dynamic web applications!

MYSQL Subquery

Download JS

Leave a Comment

Index