JavaScript is a versatile programming language primarily used for web development. It enables interactive and dynamic content on websites, allowing for client-side scripting. JavaScript
works alongside HTML and CSS, playing a crucial role in creating responsive and engaging user interfaces. It supports both procedural and object-oriented programming paradigms and is widely supported by web browsers. Additionally, JavaScript has expanded its usage beyond the web, finding applications in server-side development (Node.js) and mobile app development (React Native).
Some Of the basic example of Javascript :
- Hello, World!
console.log("Hello, World!");
- Variables and Data Types :
let age = 25;
let name = "Manish";
let isStudent = true;
- Conditional Statements:
if (age >= 18) {
console.log("You are an adult.");
} else {
console.log("You are a minor.");
}
- Loops:
for (let i = 1; i <= 5; i++) {
console.log("Count: " + i);
}
- Functions:
function greet(name) {
return "Hello, " + name + "!";
}
let greeting = greet(Sajak);
console.log(greeting);
These examples cover basic concepts like outputting to the console, working with variables, using conditionals, loops, and creating function.