Java Script

// comment

Naming convention : camelCase (first word starts with simple letter 2nd word with Capital and the rest words + it’s a variable)


JavaScript (JS) is a high-level programming language that allows you to add dynamic and interactive behavior to webpages. It is primarily used for client-side scripting, meaning it runs on the user's web browser rather than on the server.

JS enables you to manipulate webpage elements, respond to user interactions, validate forms, make network requests, perform calculations, and much more.

Untitled

Here's a simple explanation of how JavaScript works:

  1. JavaScript is embedded directly into HTML documents using the <script> tag. It can also be stored in separate .js files and linked to HTML pages.
  2. When a web browser encounters JavaScript code, it executes it line by line, from top to bottom.
  3. JavaScript can access and modify the HTML document's structure, styles, and content using the Document Object Model (DOM). It provides methods and properties to interact with elements like buttons, input fields, paragraphs, etc.
  4. JavaScript can respond to various events such as button clicks, mouse movements, and keyboard inputs. Event handlers can be attached to HTML elements, allowing you to perform specific actions when those events occur.
  5. JavaScript supports variables, which are used to store data values. Variables can be assigned different types of values, such as numbers, strings, booleans, objects, and arrays.
  6. JavaScript provides control structures like conditionals (if /else statements), loops (for /while statements), and functions. These structures enable you to execute code conditionally or repeatedly, as well as organize and reuse code.

Here's a simple JavaScript (with Html) code example that demonstrates an interactive button click:

<!DOCTYPE html>
<html>
<head>
  <title>JavaScript Example</title>
</head>
<body>
  <button id="myButton">Click Me</button>

	<!--js code-->
  <script>
    // Access the button element
    var button = document.getElementById("myButton");

    // Add a click event listener to the button
    button.addEventListener("click", function() {
      // Code to be executed when the button is clicked
      alert("Button clicked!");
    });
  </script>

</body>
</html>