Day 21/100 of JavaScript Today’s topic : Classes in JavaScript Classes in JavaScript are a cleaner syntax over prototype-based inheritance 🔹Basic class class Person { constructor(name) { this.name = name; } greet() { console.log(`Hello, ${this.name}`); } } const user = new Person("Apsar"); user.greet(); 🔹Inheritance class Student extends Person { constructor(name, course) { super(name); this.course = course; } study() { console.log(`${this.name} studies ${this.course}`); } } const s1 = new Student("Apsar", "JS"); s1.study(); 🔹Key points - "class" is syntactic sugar over prototypes. - "constructor" initializes objects. - "extends" enables inheritance. - "super()" calls parent constructor. #Day21 #JavaScript #100DaysOfCode
JavaScript Classes and Inheritance Explained
More Relevant Posts
-
#Day 3 of JavaScript Series: 🚀 Variables in JS: 📌 What is a Variable? A variable is a container used to store data values like numbers, strings, or objects. 💡 Ways to Declare Variables in JavaScript: 🔹 var Old way of declaring variables Function-scoped Can be re-declared and updated var name = "Deepika"; 🔹 let Block-scoped Can be updated but not re-declared in the same scope let age = 21; 🔹 const Block-scoped Cannot be updated or re-declared Must be initialized at declaration const country = "India"; ⚡ Key Differences: Use let when value may change Use const when value should remain constant Avoid var in modern JavaScript #JavaScript #Day3 #Variables #Coding #JavaDeveloper #LinkedinPost #Styling Raviteja T Abdul Rahman 10000 Coders
To view or add a comment, sign in
-
-
🚀 𝐃𝐚𝐲 𝟒 𝐨𝐟 𝐌𝐲 𝐉𝐚𝐯𝐚𝐒𝐜𝐫𝐢𝐩𝐭 𝐋𝐞𝐚𝐫𝐧𝐢𝐧𝐠 𝐒𝐞𝐫𝐢𝐞𝐬 Today I learned about if-else (Conditions) in JavaScript 💡 👉 Conditions are used to make decisions in code. 📌 Syntax: if (condition) { // code runs if condition is true } else { // code runs if condition is false } 📌 Example: let age = 18; if (age >= 18) { console.log("You can vote"); } else { console.log("You cannot vote"); } 👉 Also learned about: else if → check multiple conditions 📌 Example: let marks = 75; if (marks > 90) { console.log("Grade A"); } else if (marks > 60) { console.log("Grade B"); } else { console.log("Grade C"); } 👉 Conditions help in building real-world logic 💻✨ 💬 Question: Have you used if-else in any project yet? Let’s learn together 🚀 #JavaScript #WebDevelopment #LearningInPublic #Day4 #FrontendDevelopment
To view or add a comment, sign in
-
-
Day 2 of My JavaScript Journey 🚀 Today, I learned about values and variables in JavaScript. Values are the most fundamental unit of information in programming. Everything in JavaScript is built around values; numbers, text, true/false, etc. Variables, on the other hand, are like containers (or boxes) used to store these values so they can be reused later in a program. For example: let age = 20; Here, "20" is the value, and "age" is the variable storing it. One simple way to understand it: Values = the data Variables = where the data is stored Key takeaway: Variables make it easier to manage and reuse data efficiently in your code. I’m documenting my journey daily as I grow in JavaScript. #JavaScript #WebDevelopment #LearningInPublic #100DaysOfCode
To view or add a comment, sign in
-
Hello Connections! 👋 This JavaScript trick confuses 90% of beginners — will you get it right? console.log("5" - 2); // ? console.log("5" + 2); // ? Most people expect similar behavior… but JavaScript has other plans 😅 Let’s break it down: 👉 "5" - 2 JavaScript converts "5" (string) into a number automatically Result: 3 👉 "5" + 2 Here, + acts as string concatenation, not addition Result: "52" 💡 Why does this happen? Because of Type Coercion in JavaScript: - ➝ forces numeric conversion + ➝ prefers string concatenation if one operand is a string Real Lesson: JavaScript is powerful… but also tricky. If you don’t understand type coercion, bugs will find you before you find them. 😄 📌 Save this post — you’ll definitely face this in interviews or real projects. hashtag #JavaScript #JS #FrontendDevelopment #CodingTips #Programming #WebDevelopment #CodeNewbie #TechLearning #InterviewPrep #DevelopersLife #python
To view or add a comment, sign in
-
-
📚 What I Studied Today – JavaScript Functions & Array Methods Today I strengthened my understanding of some core JavaScript concepts: 🔹 Functions A function is a block of code written once and reused multiple times to perform a specific task. 🔹 Function Definition vs Call - Function Definition: Declares a function with parameters - Function Call: Executes the function using arguments 👉 Parameters = values inside () in definition 👉 Arguments = values inside () in call 🔹 Important Concepts - Parameters act like local variables (accessible only inside the function) - Functions help reduce redundancy (avoid repeating code) - Arrow functions provide a shorter syntax using "=>" 🔹 Callbacks & Higher Order Functions - A callback function is passed as an argument to another function - "forEach()" is a higher order method because it takes a function as input 🔹 Array Methods - "map()" → transforms each element into a new array - "filter()" → selects elements based on a condition - "reduce()" → reduces array to a single value (sum, total, etc.) 🚀 Slowly building a strong foundation in JavaScript! #JavaScript #WebDevelopment #CodingJourney #Learning #MERN
To view or add a comment, sign in
-
-
Day 11 of My JavaScript Journey 🚀 Today, I learned about objects in JavaScript. Objects are used to store data in key-value pairs, making it easier to organize related information. Example: const user = { name: "John", age: 25 }; Objects are written using curly brackets {}. I also learned how to retrieve and update data in objects using: • Dot notation: user.name • Bracket notation: user["name"] Both methods allow you to access and modify object properties. One thing I realized: Objects are powerful for structuring data in a more meaningful way. Key takeaway: Understanding objects is essential for working with real-world data in JavaScript. #JavaScript #WebDevelopment #LearningInPublic #100DaysOfCode
To view or add a comment, sign in
-
🔥 Day 17/30 of JavaScript Challenge Today’s problem: LeetCode 2622 – Time Limited Cache A really fun problem combining Map + asynchronous behavior (setTimeout) ⏳ 🧩 Approach: Used a Map to store: key → { value, timeoutRef } set(key, value, duration): Check if key already exists If yes → clear previous timeout to prevent early deletion Store new value and start a fresh timer using setTimeout Return true if key existed and wasn’t expired get(key): Return stored value if present, else -1 count(): Return current size of map (only non-expired keys remain) ⚡ Complexity: Time: set() → O(1) get() → O(1) count() → O(1) Space: O(n) (for storing active keys) 💡 Key Learning: Handling expiration logic correctly is crucial — clearing old timers avoids memory leaks and incorrect deletions. ⏱️ Status: Completed ✅ #Day17 #LeetCode2622 #JavaScript #AsyncJS #DSA #CodingJourney
To view or add a comment, sign in
-
-
JS 02 : Logic building with JavaScript 💻 🚀 I just wrapped up a project practicing conditional logic by building a dynamic grading system. It might look simple, but mastering if-else flows is the foundation for handling complex data later on. In this snippet: • Used prompt() to capture user input. • Implemented nested logic to categorize scores. • Focused on clean, readable code. Huge thanks to everyone supporting my growth in web development! #JavaScript #WebDevelopment #CodingJourney #LearningToCode #EngineeringStudent #AmarjeetSir Gravity Coding
To view or add a comment, sign in
-
🚀 Understanding Recursion + Finding Maximum in Nested Arrays (JavaScript) Today I practiced a powerful concept in JavaScript — recursion with nested arrays — and used it to solve a real problem: 👉 Find the maximum number from a deeply nested array 💡 Example: [1, 0, 7, [2, 5, [10], 4]] 🔍 Approach I followed: ✅ Step 1: Used recursion to flatten the nested array If the element is a number → push into result If it’s an array → call the same function again ✅ Step 2: After flattening, used a loop to find the maximum value 🧠 Key Learnings: • Each recursive call creates its own memory (execution context) • Data is temporarily stored in the call stack • The return keyword helps pass results back step by step • Without capturing the returned value, recursion results can be lost • Breaking problems into smaller parts makes complex logic easier ⚡ Final Output: 👉 Maximum number: 10 💬 This exercise really helped me understand: How recursion works internally How data flows through function calls Difference between primitive and reference types #JavaScript #Recursion #ProblemSolving #WebDevelopment #CodingJourney
To view or add a comment, sign in
-
🚀 Day 2/108 – Variables in JavaScript (var, let, const) Continuing my 108-day JavaScript journey — today I learned about variables 👇 👉 What are Variables? Variables are containers used to store data values in a program. In JavaScript, we mainly use 3 types: var, let, and const 🔹 var • Old way of declaring variables • Function scoped • Can be re-declared and updated 🔹 let • Block scoped • Can be updated but not re-declared in the same scope 🔹 const • Block scoped • Cannot be updated or re-declared • Must be initialized when declared 💻 Example: var name = "John"; let age = 22; const country = "India"; age = 23; // allowed // country = "USA"; ❌ not allowed 🧠 Key Insight: Always prefer let and const over var in modern JavaScript. 🔥 Learning step by step — consistency is the key! Are you using var, let, or const in your projects? 👇 #JavaScript #WebDevelopment #CodingJourney #LearningInPublic #108DaysOfCode
To view or add a comment, sign in
-
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development