🚀 Day 88/90 – #90DaysOfJavaScript Topic covered: Today I explored how JavaScript handles String & Number primitives vs String & Number objects.s ✅ String Primitive vs String Object 👉 "Hello" → primitive (lightweight, fast) 👉 new String("Hello") → wrapper object (rarely needed) 👉 JS temporarily wraps primitives to access methods like .length, .slice(), .repeat() ✅ Number Constructor 👉 new Number("34") → Number object (typeof → "object") 👉 Number("34") → converts to number (typeof → "number") ✅ Type Conversion Rules 👉 Number("45") → ✅ 45 👉 Number("abc") → ❌ NaN 👉 Number(true) → ✅ 1 👉 Number(null) → ✅ 0 👉 Number(undefined) → ❌ NaN 👉 Arrays & objects behave differently in numeric conversion ✅ Key Rule 👉 Always use Number(value) for conversion ❌ Avoid new Number() unless absolutely necessary 🧠 Takeaway: JS primitives are faster & efficient — wrapper objects only exist to give methods to primitives. Prefer primitives for real-world use. 🛠️ Access my GitHub repo for all code and explanations: 🔗 https://lnkd.in/e347pqH7 Let’s learn together! Follow my journey to #MasterJavaScript in 90 days! 🔁 Like, 💬 comment, and 🔗 share if you're learning too. #JavaScript #WebDevelopment #CodingChallenge #Frontend #JavaScriptNotes #MasteringJavaScript #GitHub #LearnInPublic
JavaScript primitives vs objects: A key distinction for #90DaysOfJavaScript
More Relevant Posts
-
*5 Things I Wish I Knew When Starting JavaScript 👨💻* Looking back, JavaScript was both exciting and confusing when I started. Here are 5 things I wish someone had told me earlier: *1. `var` is dangerous. Use `let` and `const`* – `var` is function-scoped and can lead to unexpected bugs. `let` and `const` are block-scoped and safer. *2. JavaScript is asynchronous* – Things like `setTimeout()` and `fetch()` don’t behave in a straight top-down flow. Understanding the *event loop* helps a lot. *3. Functions are first-class citizens* – You can pass functions as arguments, return them, and even store them in variables. It’s powerful once you get used to it. *4. The DOM is slow – avoid unnecessary access* – Repeated DOM queries and manipulations can hurt performance. Use `documentFragment` or batch changes when possible. *5. Don’t ignore array methods* – `map()`, `filter()`, `reduce()`, `find()`… they make code cleaner and more readable. I wish I started using them sooner. 💡 *Bonus Tip:* `console.log()` is your best friend during debugging! If you’re starting out with JS, save this. And if you're ahead in the journey — what do *you* wish you knew earlier? #JavaScript #WebDevelopment #CodingJourney #Frontend #LearnToCode #DeveloperTips
To view or add a comment, sign in
-
🔥 Master JavaScript String Methods in Minutes! Strings are everywhere — from user input to API responses. Knowing how to manipulate them efficiently can save you tons of time. Here’s a handy visual cheatsheet of the most used String methods: ✨ .charAt() → grab a character ✨ .concat() → merge strings ✨ .startsWith() / .endsWith() → quick checks ✨ .includes() → search inside strings ✨ .padStart() / .padEnd() → formatting made easy ✨ .repeat() → repeat content ✨ .replace() → swap text ✨ .split() → break into arrays ✨ .toUpperCase() / .toLowerCase() → change casing ✨ .trim() → clean extra spaces Save this for later 🔖 and never get stuck Googling again. 💬 What’s your most used String method in real projects? hashtag#JavaScript hashtag#WebDevelopment hashtag#Frontend hashtag#Coding hashtag#SoftwareEngineering hashtag#100DaysOfCode hashtag#JavaScriptTips
To view or add a comment, sign in
-
-
🔥 JavaScript: When “prototype” is NOT an object 👀 We all learn early — > “Every function in JavaScript has a prototype property that is an object.” But JavaScript loves exceptions 😏 Here are some surprising cases where prototype is not an object 👇 RegExp.prototype // → /(?:)/ Array.prototype // → [] Function.prototype // → ƒ () {} Number.prototype // → Number {} String.prototype // → String {} Boolean.prototype // → Boolean {} Symbol.prototype // → Symbol {} BigInt.prototype // → BigInt {} 💡 Notice something? Some of these are functions, arrays, or even regular expressions! That’s because their prototypes are actual instances of their types, not plain objects — so that all instances inherit their core methods directly. For example: Array.prototype.push === [].push // true ✅ RegExp.prototype.test === /abc/.test // true ✅ So next time you assume prototype is always {}, remember — JS is full of living examples 😉 --- 💬 Have you ever found a weird prototype behavior while debugging? Drop it in the comments — let’s break more JS myths together! ⚙️ #JavaScript #WebDevelopment #LearningEveryday #Frontend
To view or add a comment, sign in
-
🚀 Day 30/50 – Function Currying in JavaScript Think of Function Currying like building a relationship. You don’t propose directly 😅 First comes the “Hi Hello 👋” phase → then friendship ☕ → and finally… the proposal ❤️ In JavaScript, instead of passing all arguments at once, Function Currying lets us pass them step by step, each step returning a new function until the final output is achieved. Here’s a simple code analogy from my video: function proposeTo(crush) { return function (timeSpent) { return function (gift) { return `Dear ${crush}, after ${timeSpent} of friendship, you accepted my ${gift}! 🥰`; }; }; } console.log(proposeTo("Sizuka")("3 months")("red rose 🌹")); Each function takes one argument and returns another function — making the code modular, flexible, and easy to reuse. 👉 This is Function Currying — one argument, one step, one perfect result. 🎥 Watch the full short video here: 🔗 https://lnkd.in/g-NkeYBc --- 💡 Takeaway: Function Currying isn’t just a JavaScript trick — it’s a powerful pattern for cleaner, more composable functions that enhance reusability and maintainability in modern frontend code. --- Would love to know: 👉 What’s your favorite JavaScript concept that clicked instantly when you saw it explained simply? #javascript #frontenddevelopment #webdevelopment #coding #programming #softwareengineering #learnjavascript #100daysofjavascript #techsharingan #developers #careergrowth
To view or add a comment, sign in
-
Variable Declarations @ JavaScript Simplified👨💻 In JavaScript, we have three keywords to declare variables: var, let, and const. 💢Each behaves differently when it comes to redeclaration and reassignment 👇 🔸 var ✅ Redeclaration: Allowed ✅ Reassignment: Allowed 🧩 Example: var x = 10; var x = 20; // works fine ⚠️ Best avoided — can cause accidental overwriting of variables. 🔸 let ❌ Redeclaration: Not allowed ✅ Reassignment: Allowed 🧩 Example: let y = 30; y = 40; // valid let y = 50; // ❌ SyntaxError 👍 Use let when the value of a variable might change later. 🔸 const ❌ Redeclaration: Not allowed ❌ Reassignment: Not allowed 🧩 Example: const z = 50; z = 60; // ❌ TypeError 🔒 Use const for values that should never change. 👉 Quick recap: 🔹Use let when updates are needed. 🔹Use const when the value stays fixed. 🔹Avoid var to keep your code predictable and clean. #JavaScript #WebDevelopment #CodingTips #LearningJS #FrontendDevelopment
To view or add a comment, sign in
-
🚫 Stop Saying “Variables Are Moved to the Top” The Real Explanation of Hoisting in JavaScript “Variables are moved to the top of their scope” — a phrase I’ve heard countless times in JavaScript tutorials. After working extensively with JS, I realized this explanation often causes confusion. The real story is more nuanced. 🔍 What Hoisting Actually Is Hoisting is not the JavaScript engine moving code around. Instead, during the compilation phase, JavaScript: - Scans the scope - Allocates memory for variable and function declarations - Sets up how each variable behaves when accessed 🟡 var vs let / const During Hoisting var - Memory is allocated - Initialized with undefined - Accessible before declaration (but returns undefined) let and const - Memory is reserved - Not initialized Stay in the Temporal Dead Zone (TDZ) until the actual declaration Accessing them early throws a ReferenceError Example console.log(a); // undefined var a = 10; console.log(b); // ReferenceError let b = 20; ⭐ Key Points to Remember - Only declarations are hoisted — not assignments - Function declarations are fully hoisted and available before they appear in code - let and const use the TDZ (Temporal Dead Zone), which is essential to understand for debugging and writing reliable code
To view or add a comment, sign in
-
💛 𝗗𝗮𝘆 𝟮 — 𝗝𝗮𝘃𝗮𝗦𝗰𝗿𝗶𝗽𝘁: 𝗩𝗮𝗿𝗶𝗮𝗯𝗹𝗲𝘀, 𝗦𝗰𝗼𝗽𝗲, 𝗮𝗻𝗱 𝗛𝗼𝗶𝘀𝘁𝗶𝗻𝗴 Today, I revisited one of the most confusing yet powerful concepts in JavaScript — 𝗵𝗼𝗶𝘀𝘁𝗶𝗻𝗴 and 𝘀𝗰𝗼𝗽𝗶𝗻𝗴. 🧠 💡 𝗖𝗼𝗻𝗰𝗲𝗽𝘁: JavaScript moves all declarations to the top of their scope during compilation — this is known as hoisting. However, the behavior differs based on whether you use var, let, const, or functions. 💻 𝗖𝗼𝗱𝗲 𝗦𝗻𝗶𝗽𝗽𝗲𝘁: console.log(a); // undefined (hoisted) var a = 10; console.log(b); // ❌ ReferenceError (in TDZ) let b = 20; sayHello(); // ✅ Works — function declarations are hoisted function sayHello() { console.log("Hello from a hoisted function!"); } // ❌ Error: sayHi is not a function sayHi(); var sayHi = function () { console.log("Hi from function expression!"); }; 🧩 𝗘𝘅𝗽𝗹𝗮𝗻𝗮𝘁𝗶𝗼𝗻: 0. var is hoisted and initialized with undefined. 1. let and const are hoisted but stay uninitialized in the temporal dead zone (TDZ). 2. Function declarations are fully hoisted, so you can call them before defining. 3. Function expressions (especially when assigned to var) behave like variables — hoisted but not initialized. 📈 𝗦𝗰𝗼𝗽𝗲 𝗪𝗶𝘀𝗱𝗼𝗺: var → function scope let & const → block scope Functions → create their own local scope 🔥 𝗧𝗮𝗸𝗲𝗮𝘄𝗮𝘆: Understanding how JavaScript creates and executes contexts will help you debug faster and think more like the JS engine itself. #JavaScript #100DaysOfCode #Hoisting #Scope #Functions #FrontendDevelopment #LearningEveryday
To view or add a comment, sign in
-
Day 73 of #100DaysOfCode Today I dove into Object-Oriented JavaScript specifically Classes and the this keyword. In JavaScript, a class is like a blueprint for creating multiple objects with shared structure and behavior. It can include: A constructor() → initializes properties Methods → define actions for class instances Example: class Dog { constructor(name) { this.name = name; } bark() { console.log(`${this.name} says woof!`); } } const dog = new Dog("Gino"); dog.bark(); // Gino says woof! Here, this refers to the current object instance. In methods, it gives access to that object’s properties and behaviors. Key takeaways 🧠 Classes make code reusable and modular. this ensures context, it points to who is calling the method. Arrow functions don’t create their own this; they inherit from their scope. Mastering these two concepts is a huge step toward writing cleaner, scalable JavaScript.
To view or add a comment, sign in
-
🚀 Day 11 of My 30 Days of JavaScript Journey ✅ Challenge: Memoize (LeetCode #2623) The task was to create a memoize(fn) function that caches results so that repeated calls with the same inputs return instantly from cache — without re-executing the original function. This helps improve performance when dealing with expensive computations like fibonacci or factorial, and even simple operations like sum when called repeatedly. 💻 Language Used: JavaScript ❓ Problem Link: https://lnkd.in/gnHmbPih 💡 Solution: https://lnkd.in/gGJZjYY9 🧠 Concept Highlighted: Memoization is a powerful optimization technique that uses caching to avoid repeating calculations. It strengthens understanding of closures, function arguments handling, and performance-oriented JavaScript. #JavaScript #LeetCode #30DaysOfCode #CodingChallenge #WebDevelopment #FrontendDevelopment #Memoization #PerformanceOptimization #LearningEveryday #ProblemSolving
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