JavaScript Basics: Variables and Data Types

🚀 JavaScript Basics, I Practiced Today As I continue learning JavaScript, today I practiced some important fundamentals that every beginner should understand. These small concepts are the building blocks of real web applications. 1️⃣ var, let, const These are used to declare variables in JavaScript. Example: var name = "Amit"; let age = 22; const country = "Bangladesh"; console.log(name); console.log(age); console.log(country); Difference- var, let and const: • var → Old way of declaring variables. • let → Value can be changed. • const → Value cannot be changed. Example: let score = 10 let score = 20 // allowed ( // this is a comment tag). const pi = 3.14; // const pi = 3.15 ❌ not allowed. 2️⃣ JavaScript Data Types: Data types tell us what type of value a variable stores. JavaScript has two main types of data: 1️⃣ Primitive Data Types 2️⃣ Non-Primitive Data Types 🟢 Primitive Data Types Primitive values are simple and store a single value. Examples: • String: let name = "Amit"; console.log(name); • Number: let age = 22 • Boolean: Boolean valu is true or false. let isStudent = true; • Undefined: Not define any value. let city; console.log(city); • Null let data = null; 🟢 Non-Primitive Data Types: Non-primitive types can store multiple values. Examples: • Object let user = { name: "Amit", age: 22 } console.log(user.name) • Array: let skills = ["HTML", "CSS", "JavaScript"]; console.log(skills[0]); 💡 My Learning Insight Understanding variables and data types is essential before moving to advanced topics like DOM manipulation, APIs, and React. I believe the best way to learn programming is by building projects and practicing daily. Currently working toward becoming a MERN Stack Developer. 💬 What JavaScript concept should I learn next? #javascript #webdevelopment #frontenddeveloper #learninginpublic #mern

Currently learning JavaScript and trying to understand how the DOM works. If you have any tips or resources that helped you when starting with JS, feel free to share. I would really appreciate it!

Like
Reply

To view or add a comment, sign in

Explore content categories