JavaScript Introduction

What is JavaScript?

  1. JavaScript is a high-level, interpreted scripting language that adds interactivity and functionality to web pages.
  2. It runs in web browsers, making it an essential part of web development.

Including JavaScript in HTML

  1. You can include JavaScript code in your HTML document using the <script> tag in the <head> or <body> section.
<script>
    // JavaScript code goes here
</script>

/* OR */

<script src="fileName.js"></script> // Include your JavaScript File name by replacing "fileName.js"
  

JavaScript Advantages

  1. Web development
  2. Mobile development
  3. Game development
  4. Server-side development

What we can do with JavaScript?

  1. Create interactive web pages, such as menus, forms, and animations.
  2. Develop web applications, such as online games and social media platforms.
  3. Build server-side applications with Node.js.
  4. Create mobile apps using frameworks like React Native.
  5. Develop data science and machine learning applications.

How JavaScript Works

  1. When you run a JavaScript program, the interpreter reads the code line by line and executes it.
  2. This is in contrast to compiled languages, where the entire program is converted into machine code before it is executed.
  3. JavaScript is also a single-threaded language. This means that it can only execute one task at a time.
  4. However, it can achieve concurrency by using an event loop.
  5. The event loop is a mechanism that allows JavaScript to handle multiple events simultaneously, even though it can only execute one task at a time.

JavaScript Terminology

  1. Variable: A named storage location for data.
  2. Function: A reusable block of code that performs a specific task.
  3. Object: A collection of properties and values.
  4. Array: A data structure that stores a collection of ordered elements.
  5. String: A sequence of characters.
  6. Number: A numeric value.
  7. Scope: The region of code where a variable is accessible.
  8. Hoisting: The process of moving variable declarations to the top of their scope.
  9. Callback function: A function that is passed to another function as an argument.
  10. Event: An action that occurs in the browser, such as a click or a keyboard press.
  11. DOM: The Document Object Model, which is a representation of the HTML document in memory.
  12. BOM: The Browser Object Model, which provides access to the browser's features and functionality.