🚀 Day 29 - 💡 JavaScript Tricky Question Explanation let a = [1,2,3]; delete a[1]; console.log(a); console.log(a.length); 👉 Output: ``` [1, empty, 3] 3 ``` 👉 Explanation: * `delete` removes the value but does NOT reindex the array * It creates a hole (empty slot) instead of shifting elements * So, `length` remains 3 ⚠️ Use `splice()` if you want to remove and shift elements #JavaScript #WebDevelopment #Frontend #CodingInterview #JSConcepts
JavaScript Array Delete Explanation
More Relevant Posts
-
🚀 💡 JavaScript Tricky Question Explanation const arr = [4, 10, 2, 8]; const result = arr.find(num => num > 5) + arr.findIndex(num => num > 5); console.log(result); 👉 Output: 11 👉 Explanation: * find() returns the first value > 5 → `10` * findIndex() returns its index → `1` * Final result → `10 + 1 = 11` ⚡ Both stop at the **first match** #JavaScript #WebDevelopment #Frontend #CodingInterview #JSConcepts
To view or add a comment, sign in
-
🚀 Day 30 - 💡 JavaScript Tricky Question Explanation const arr = [4, 10, 2, 8]; const result = arr.find(num => num > 5) + arr.findIndex(num => num > 5); console.log(result); 👉 Output: 11 👉 Explanation: * find() returns the first value > 5 → `10` * findIndex() returns its index → `1` * Final result → `10 + 1 = 11` ⚡ Both stop at the **first match** #JavaScript #WebDevelopment #Frontend #CodingInterview #JSConcepts
To view or add a comment, sign in
-
Most devs reach for a state management library too fast. Before you install Redux or Zustand, try this 👇🏾 // Manage related state together, not separately const [form, setForm] = useState({ name: '', email: '', password: '' }) const handleChange = (e) => { setForm(prev => ({ ...prev, [e.target.name]: e.target.value })) } One state object. One handler. Works for 90% of forms. Stop adding dependencies before you need them. Save this 🔖 #ReactJS #JavaScript #WebDevelopment #Fullstack #CodingTips
To view or add a comment, sign in
-
-
🚀 Most devs use Next.js every day but don't fully understand what happens under the hood. Let me break down Server vs Client Components in 60 seconds — and what the RSC Payload actually is. 🖥️ On the Server Next.js splits rendering by route segment (layouts + pages). → Server Components → rendered into an RSC Payload → Client Components + RSC Payload → prerendered HTML 📦 What is the RSC Payload? A compact binary representation of your Server Component tree. It contains 3 things: ✅ Rendered result of Server Components ✅ Placeholders + JS references for Client Components ✅ Props passed from Server → Client Components 💡 Why does this matter? React uses the RSC Payload on the client to update the DOM — not re-render everything from scratch. That's how Next.js gives you fast, seamless navigations while keeping server-rendered content fresh. Understanding this model helps you: → Write leaner bundles (keep logic server-side) → Pass props correctly across the boundary → Avoid hydration mismatches that are hard to debug #NextJS #React #WebDev #Frontend #JavaScript #ImmediateJoiner #CoreWebVitals
To view or add a comment, sign in
-
useEffect — The Hook That Confused Me (Until I Got This) useEffect was confusing until I understood one thing: dependencies control everything. The Rule: javascript // Runs ONCE after mount useEffect(() => { fetchData(); }, []); // Runs when userId changes useEffect(() => { fetchUser(userId); }, [userId]); // Runs on EVERY render (avoid!) useEffect(() => { console.log('render'); }); What I Learned the Hard Way: Missing dependencies = stale data Adding everything = infinite loops Cleanup functions matter (especially for subscriptions) My Checklist: What should trigger this effect? Do I need to clean up? Can this cause unnecessary renders? What's your React Hook survival tip? #ReactJS #JavaScript #FrontendDeveloper #WebDev #CodingTi
To view or add a comment, sign in
-
🧠 Day 10 of 21days challenge JavaScript call, apply, bind 🔥 They allow you to control what “this” refers to in a function. You can borrow functions and use them with different objects. For easy understanding :- call → pass arguments one by one apply → pass arguments as array bind → returns new function 👉 That’s how we control “this” in JavaScript This changed how I understand functions 🚀 #JavaScript #CallApplyBind #Frontend
To view or add a comment, sign in
-
-
One of the most underrated JavaScript concepts I have come across is microtask starvation. Most of us know that promises run before things like setTimeout. That part is simple. But the interesting part is what happens when you keep adding microtasks continuously. ```js function loop() { Promise.resolve().then(loop); } loop(); setTimeout(() => { console.log("This will never run"); }, 0); ``` What is happening here? Every time the microtask runs, it schedules another one. The event loop keeps clearing microtasks and never moves to the macrotask queue. Result: setTimeout never runs UI updates can get blocked The app can feel frozen without clear errors The real takeaway is this Microtasks do not give control back to the event loop easily. If you use them carelessly in recursive patterns, you can block everything else. In some cases, it is actually better to use setTimeout or similar approaches to let the system breathe. This is not something you see often in tutorials, but it can quietly cause real production issues. #JavaScript #EventLoop #Frontend #WebPerformance
To view or add a comment, sign in
-
🧠 Day 18 of 21days challenge JavaScript WeakMap ⚡ WeakMap is a collection where keys must be objects. It helps in memory management because keys are weakly referenced. For easy understanding :- WeakMap = object keys only Garbage collected if no other references Useful to store private data 👉 That’s how memory leaks can be prevented This changed how I manage objects efficiently 🚀 #JavaScript #WeakMap #InterviewPrep #Frontend
To view or add a comment, sign in
-
-
Most JS developers use closures daily without knowing it. counter() finished running, but increment still remembers count. That's a closure. How does it remember? When a function is created in JavaScript, it doesn't just save the code — it also saves a reference to the variables around it at that moment. So even after the outer function is gone, that reference stays alive in memory as long as the inner function exists. Think of it like this the inner function carries a backpack of its outer variables wherever it goes. 🎒 You already use this in React's useState, debounce, and event handlers. Once I understood this, my React bugs started making sense. 🙂 Did closures confuse you at first? Drop a comment 👇 #JavaScript #MERN #WebDevelopment #LearningInPublic
To view or add a comment, sign in
-
-
learned optional chaining in react today. making: IPL project 🏏 issue faced: accessing nested objects like "object.object.object" fix/learned: optional chaining ("?.") to avoid crashes & undefined errors small thing, big sanity save. #reactjs #webdev #buildinpublic #javascript
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