1. Home
  2. Docs
  3. Web Technology I
  4. JavaScript-Client Side Sc...
  5. Introduction

Introduction

Here is the Introduction of JavaScript:

  • Dynamic Typing: Variables can dynamically change their data types.
  • Prototypal Inheritance: Objects can inherit properties and methods from other objects through prototypes.
  • Functions as First-Class Citizens: Functions can be assigned to variables, passed as arguments, and returned as values.
  • Asynchronous Programming: Supports asynchronous operations using callbacks, Promises, and async/await.

  • Client-Side Scripting: Used in web browsers to manipulate HTML, CSS, and handle events.
  • Server-Side Development: With platforms like Node.js, JavaScript can be used for server-side scripting.
  • Mobile App Development: Frameworks like React Native and NativeScript allow building mobile apps using JavaScript.
  • Game Development: JavaScript is used for developing browser-based games.

// Prompt the user for their name
var userName = prompt("What's your name?");

// Check if the user entered a name
if (userName !== null && userName !== "") {
    // Display a personalized greeting
    var greeting = "Hello, " + userName + "!";
    alert(greeting);
} else {
    // Handle case where the user didn't enter a name
    alert("Hello there!");
}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>JavaScript Example</title>
</head>
<body>

    <h1>JavaScript Example</h1>

    <!-- Adding JavaScript within the HTML file -->
    <script>
        // Your JavaScript code goes here
        document.write("Hello, World!");
    </script>

    <!-- External JavaScript file -->
    <script src="script.js"></script>

</body>
</html>
  • Single-Line Comments
  • Multi-Line Comments

// This is a single-line comment
var x = 5;  // This is an inline comment
/* This is a
   multi-line comment */
var y = 10;
// This is a single-line comment

/*
   This is a multi-line comment.
   It can span multiple lines.
*/

var a = 42;  // Another single-line comment
Tags , ,

How can we help?

Leave a Reply

Your email address will not be published. Required fields are marked *