Introduction
What is JavaScript?
- Javascript is a high-level, dynamic, object-oriented programming language used for web development
- It is primarily executed in web browsers to add interactivity and create dynamic web pages.
Link JavaScript File in HTML
There are two ways to add JavaScript to an HTML file:
1. Internal JS:
- We can add JavaScript directly to o HTML file by writing the code inside the <script> tag.
- The <script> tag can be placed inside the <head> or the <body> tag.
2. External JS:
- Write JavaScript code in files having an extension .js and then link this file inside the <head> tag of the HTML file in which we want to add this code.
Features of JavaScript:
- Interactivity: We can create interactive web pages by responding to user actions, such as clicks, keyboard input, and mouse movements.
- Dynamic Typing: JavaScript is dynamically typed, language means you don't need to declare data types for variables.
- Versatility: JavaScript is used for a wide range of tasks beyond web development. It can be used for server-side scripting (Node.js), game development, mobile app development, desktop application development, and more.
- Scripting Language: JavaScript is a "scripting language" because it is typically executed line by line, making it well-suited for tasks that require automation and user interaction.