JavaScript
JavaScript is a lightweight interpreted programming language with first-class functions. It allows us to add interactivity and functionality to websites. Javascript is used for creating dynamic websites. It is also used for communication with web servers. It is also known as the scripting language for web pages. It supports object-oriented imperative and declarative styles.
“JavaScript is not “Interpreted Java” ”.
The standards for Javascript are the ECMAScript language specification (ECMA-262).
History of the JavaScript
The founder of the javascript language is Brendan Eich.
Brendan Eich and his team members developed the JavaScript language into Netscape Communication Corporation in 1995.
There are very interesting parts when we want to know how the name is given to JavaScript. Initially, it was named LiveScript. But after some time developers see that LiveScript is not becoming famous. At that time one language was the very popular “Java Language”. Then developers give the name JavaScript. After that javascript became famous because many developers think that Java and Javascript both are interpreted. That’s why developers give the name JavaScript.
JavaScript can be used on the server side (Node.js) for back-end development. It also plays a very crucial part in front-end web development.
The syntax of JavaScript is very similar to other languages just as C++ and Java.
There are various types of data types present in JavaScript such as numbers, strings, booleans, arrays, and objects.
JavaScript allows us to manipulate the DOM, which represents the structure of an HTML document.
// This is a comment
// Declaring variables
var x = 5; // Using the 'var' keyword to declare a variable
let y = 10; // Using the 'let' keyword to declare a variable (introduced in ES6)
const z = 15; // Using the 'const' keyword to declare a constant variable
// Basic data types let name = "John";
// String let age = 30;
// Number let isStudent = true;
// Boolean let fruits = ["apple", "banana", "cherry"];
// Array let person = { firstName: "John", lastName: "Doe" };
// Object
// Functions function greet(name)
{ console.log("Hello, " + name + "!"); }
// Calling a function greet(name);
// Output: Hello, John!
// Conditional statements
if (age >= 18)
{
console.log("You are an adult.");
} else
{
console.log("You are a minor.");
} // Loops
for (let i = 0; i < 5; i++)
{
console.log("Iteration " + (i + 1));
} // Array iteration
fruits.forEach(function(fruit)
{
console.log("I have a " + fruit);
});
// Object
console.log(person.firstName + " " + person.lastName);