Mastering JavaScript Basics for Web Development

🚀 Mastering the Basics of JavaScript — the language that brings websites to life! From variables and functions to DOM manipulation, every concept builds the foundation of modern web development. 💻✨ Here’s clear and structured content on Basics of JavaScript. 📌 Basics of JavaScript 🔹 What is JavaScript? JavaScript (JS) is a high-level, interpreted programming language used to make websites interactive and dynamic. It works along with: HTML → Structure CSS → Style 🔹 Features of JavaScript ✔ Lightweight & fast ✔ Object-Oriented ✔ Event-driven ✔ Interpreted language ✔ Platform-independent 🔹 1. Variables in JavaScript Variables are used to store data. ✅ var Old way of declaring variables (function-scoped). var name = "Anshika"; ✅ let Block-scoped variable (recommended). let age = 22; ✅ const Used for constant values (cannot be reassigned). const pi = 3.14; 🔹 2. Data Types in JavaScript 📌 Primitive Data Types 1. String → "Hello" 2. Number → 10 3. Boolean → true / false 4. Undefined 5. Null 6. BigInt 7. Symbol let name = "JavaScript"; let marks = 95; let isPass = true; 🔹 3. Operators in JavaScript ➤ Arithmetic Operators + - * / % let a = 10; let b = 5; console.log(a + b); // 15 ➤ Comparison Operators == === != > < == → compares value === → compares value + type console.log(5 == "5"); // true console.log(5 === "5"); // false 🔹 4. Conditional Statements Used to make decisions. ✅ if-else let age = 18; if (age >= 18) { console.log("Eligible to vote"); } else { console.log("Not eligible"); } ✅ switch let day = 1; switch(day) { case 1: console.log("Monday"); break; default: console.log("Invalid day"); } 🔹 5. Loops in JavaScript ➤ for loop for (let i = 1; i <= 5; i++) { console.log(i); } ➤ while loop let i = 1; while (i <= 5) { console.log(i); i++; } 🔹 6. Functions in JavaScript Functions are reusable blocks of code. ✅ Normal Function function greet(name) { return "Hello " + name; } console.log(greet("Anshika")); ✅ Arrow Function (ES6) const add = (a, b) => a + b; console.log(add(5, 3)); 🔹 7. Arrays Used to store multiple values. let fruits = ["Apple", "Banana", "Mango"]; console.log(fruits[0]); // Apple 🔹 8. Objects Objects store data in key-value pairs. let student = { name: "Anshika", age: 22, course: "CSE" }; console.log(student.name); 🔹 9. DOM (Document Object Model) JavaScript can manipulate HTML elements. document.getElementById("demo").innerHTML = "Hello World!"; This makes websites interactive (like button clicks, form validation, etc.) 🔹 10. Events in JavaScript Events are actions performed by users. Example: Click Event <button onclick="showMessage()">Click Me</button> function showMessage() { alert("Button Clicked!"); } #JavaScript #WebDevelopment #FrontendDeveloper #CodingJourney #Pyspiders

  • graphical user interface, application

To view or add a comment, sign in

Explore content categories