JavaScript was developed by Brendan Eich in 1995 while working at Netscape Communications. Initially called Mocha, it was later renamed to JavaScript. JavaScript was created to enable interactive features in web pages, making them dynamic and user-friendly.
JavaScript was created by Brendan Eich in just 10 days at Netscape in 1995. Initially, it was intended to enable client-side scripting in web browsers. JavaScript was initially called Mocha and then renamed to JavaScript, which was a marketing decision to align it with the popular Java programming language at the time. Over the years, JavaScript has evolved significantly with the release of ECMAScript standards, and now it is a major language for web development.
JavaScript is a scripting language used to create and control dynamic website content. It allows developers to add interactivity to HTML pages, including tasks like form validation, animations, and handling events such as clicks and key presses. JavaScript is a client-side language, meaning it runs on the user’s browser, but it can also be used server-side with environments like Node.js.
JavaScript can be used in different contexts, such as:
JavaScript is widely used for:
In JavaScript, variables store values and can be declared using the var,
let, or const keywords. JavaScript also supports various data types, such as:
true or false
let x;
let y = null;
let fruits = ["apple", "banana"];
let person = { name: "Rohan", age: 25 };
let big = 123456789123456789n;
function greet() { alert("Hello"); }
Example of Variable Declaration:
JavaScript can be embedded in an HTML document using the <script> tag. There are two
primary ways to include JavaScript in HTML:
onclick or onload attributes.
<script> tag.Example of External JavaScript:
Example of Inline JavaScript:
A function is a reusable block of code designed to perform a specific task. It can take inputs (parameters), process them, and return an output.
Know more about Functions