Most developers use localStorage and sessionStorage without really knowing the difference. I was the same — until one bug forced me to actually read the docs. Here’s the difference 👇 🧠 localStorage - Data persists even after the browser is closed. - Great for saving user preferences, themes, or tokens that don’t expire. ⚙️ sessionStorage - Data clears once the tab or window is closed. - Perfect for temporary data like form states or one-session inputs. Both store data as key-value pairs in the browser — but persistence changes everything. I learned one rule from that bug: → “Use sessionStorage when you want memory. → Use localStorage when you want permanence.” Small detail. Big difference. #javascript #webdevelopment #frontend #softwareengineering #learnbybuilding #reactjs
Understanding localStorage and sessionStorage in JavaScript
More Relevant Posts
-
Working with tables in React ? Then you’ve got to check out React Data Table Component (RDT) one of the most powerful and easy-to-use libraries out there! ⚛️ It comes packed with built-in features like : ✨ Pagination ✨ Sorting ✨ Loading indicators ✨ Selectable Rows ✨ Expandable Rows But keep in mind these features work best for client-side data . If your data comes from an API or you’re dealing with large datasets, you’ll need to implement server-side pagination manually. Still, RDT makes building clean, responsive, and data-rich UIs a breeze! 🚀 For more details checkout their official docs : https://lnkd.in/d2pvECmu #React #JavaScript #FrontendEngineer #ReactDataTable #SoftwareDevelopment #KeepExploring
To view or add a comment, sign in
-
-
Understanding the Core of REST APIs — Every Developer Should Know This Whenever your frontend talks to your backend, it’s usually through a REST API. But what really makes an API RESTful? Here’s the breakdown: Representational State Transfer It’s all about how data travels between client and server. For example — when you make a GET request in your website, you’re just asking the server: “Hey, send me this data in JSON format!” REST APIs use simple HTTP methods like: GET → Retrieve data POST → Send data PUT → Update data DELETE → Remove data Once you truly understand this, backend development starts feeling much easier. #MERN #WebDevelopment #JavaScript #Backend #LearningInPublic #FullStackDeveloper #CodingJourney #TechConcepts
To view or add a comment, sign in
-
Most developers rely on arrays and objects, but they’re not always the right tool. When you need faster lookups or flexible keys, Set and Map offer a cleaner, more efficient approach. They help you simplify real world tasks like caching, deduplication, and managing structured data. Explore how they work: https://lnkd.in/gB4-Uzq6 #JavaScript #FrontendDevelopment #WebDevelopment #greatfrontend
To view or add a comment, sign in
-
Async Redux confused me more than the code itself. Every diagram showed a simple loop. None explained where the API actually happens. This one finally made it click. 📌 The real async Redux flow in 7 steps: 1️⃣ View: User triggers an action (FETCH_USER_REQUEST) 2️⃣ Middleware: Thunk/Saga intercepts it 3️⃣ API Call: Side effect happens here 4️⃣ Action #2: Middleware dispatches FETCH_USER_SUCCESS with payload 5️⃣ Reducer: Pure function. Updates state only on success action 6️⃣ State: Central store gets fresh data 7️⃣ View Update: React re-renders UI 🔁 That’s the loop: View → Action → Middleware → API → Action → Reducer → State → View This diagram is one of the clearest visual explanations of async data flow in Redux that I’ve seen. If you’re learning Redux, save this. 👇 I’m curious: Which async approach do you use in React today? Saga? Thunk? RTK Query? Something else? #Reactjs #Redux #JavaScript #WebDevelopment #Frontend #StateManagement #ReduxToolkit #AsyncProgramming #ReactDevelopers #SoftwareEngineering #LearningInPublic #WebDevCommunity
To view or add a comment, sign in
-
-
💡 structuredClone() vs JSON.parse(JSON.stringify()) Both are used for deep copying objects in JavaScript, but they’re not the same. 🧠 structuredClone() Creates a true deep copy (recursively copies nested data). Supports complex types: Date, Map, Set, Blob, etc. Handles circular references safely. Faster and more reliable. const clone = structuredClone(obj); ⚠️ JSON.parse(JSON.stringify()) Works only for simple JSON-safe data. Loses functions, Dates, Maps, Sets, and Symbols. Crashes on circular references. ✅ Use structuredClone() whenever available (modern browsers & Node 17+). Use the JSON trick only for plain, simple data. #JavaScript #WebDevelopment #Frontend #DeepCopy #CodingTips
To view or add a comment, sign in
-
🔁 State Lifting in React | The Smart Way to Share Data Between Components. Ever had two React components that needed to share the same data, but didn’t know how? 🤔 That’s where the concept of State Lifting comes in, one of React’s most elegant patterns. 🧩 What Is State Lifting? When two or more components need access to the same data, you lift that state up to their closest common parent. The parent manages the data, and the children receive it through props. This keeps data centralized and consistent. 🧠 Let’s See an Example. Now look the example code below, let’s say we have two child components one to input data, and one to display it. Without lifting state, they can’t “talk” to each other directly. 🧭 Here, both child components share the same state managed by their parent. 🚀That’s state lifting in action. 🧠 Best Practice Lift state only when needed, not every piece of state should live in the parent. If many components need the same state → consider React Context. Keep the flow of data unidirectional (top → down). 💬 Final Thought: State lifting teaches one of React’s golden rules. 👉 Share state by moving it up, not across. #ReactJS #MERNStack #FrontendDevelopment #WebDevelopment #ReactPatterns #ReactHooks #JavaScript #CleanCode #LearnReact #SoftwareEngineering
To view or add a comment, sign in
-
-
Context API vs. Redux: Stop the Confusion. Here’s the 2-minute rule that can help. Choosing between React's built-in Context API and the popular Redux library is a common dilemma. The key is to think about scale and frequency. ⤷Use Context API for: -Simple, infrequent updates, like a dark mode toggle or a logged-in user's name. -Avoiding "prop drilling" on a small-to-medium scale. -When you prefer a lightweight, built-in React solution with less setup. ⤷Use Redux for: -Large, complex applications with state that changes frequently. -Centralizing a single "source of truth," like a shopping cart or dashboard data. -Debugging complex state issues with powerful DevTools, which Context lacks. -Predictable state updates with a structured flow of actions and reducers. ⤷Username & Notification Example: →You have two states: -Username: Rarely changes -Notifications: Changes frequently →With Context: If you put both in one context, every time notifications update, all components showing the username re-render too. This is inefficient. To fix it, you must split your contexts, adding complexity. →With Redux: Redux lets components subscribe only to the state they need. The component showing notifications subscribes to notifications. Lot of components showing the username do not re-render when a notification arrives. ⤷The takeaway: -Context is perfect for static or low-frequency global data. -Redux shines when your state is dynamic, shared, and heavily updated. ⤷Your take: -Have you ever migrated from Context to Redux? -What was your sign that it was "time for a cannon"? Share your experience in the comments! #React #JavaScript #WebDevelopment #Redux #ContextAPI #StateManagement
To view or add a comment, sign in
-
🚀 How Node.js Really Works — V8 + libuv Explained Simply: Ever wondered how Node.js handles asynchronous code so efficiently? It’s all thanks to two core components — V8 and libuv ⚙️ 🧠 V8 Engine → The brain of Node.js It executes your JavaScript and compiles it into fast machine code (developed by Google for Chrome). ⚙️ libuv → The heart of Node.js It manages the event loop, thread pool, and handles asynchronous I/O like file reading, networking, and timers. 🔗 How they work together: 1️⃣ V8 runs your JS code 2️⃣ Async tasks go to libuv 3️⃣ libuv handles them in background threads 4️⃣ When complete, results return to V8 via the Event Loop 💡 Example: fs.readFile('data.txt', 'utf8', (err, data) => { console.log(data); }); console.log("Reading file..."); While V8 executes “Reading file…”, libuv reads the file in the background — that’s non-blocking I/O in action 🚀 Next time you write async code, remember: 🧠 V8 runs your JS, ⚙️ libuv runs the rest 💪 #NodeJs #JavaScript #Backend #WebDevelopment #Developers #TechExplained #AsyncProgramming
To view or add a comment, sign in
-
🚀 From useEffect chaos to clean useQuery simplicity! Here’s a before-after look at how Qortex makes your React data fetching experience effortless 👇 Before: Messy useEffect, manual state updates, loading and error handling everywhere 😩 After: Just one line — useQuery("user", { fetcher }) 💪 ✅ Less React lifecycle clutter ✅ Built-in caching & persistence ✅ Shared queries = no duplicate network calls ✅ No provider or boilerplate setup ✅ Simple plug-and-play It’s like React Query, but more minimal and plug-and-play friendly ⚡ 👉 Try it here: https://lnkd.in/gSyXajZn #reactjs #opensource #frontend #javascript #developerexperience #qortex
To view or add a comment, sign in
-
-
#typescript #reactjs It’s always a good practice to cancel API calls during cleanup (before the next render and when the component unmounts) to solve memory leak issues and race conditions. We can achieve this by using the built-in web API named "AbortController." We just need to pass a signal and then, in the cleanup function (the return function of `useEffect`), we can abort/cancel the API call. This is particularly relevant for those who manually call APIs without using libraries like React Query, RTK Query, or SWR. These packages handle this case out of the box, but it's beneficial to understand why we may need API cancellation and the reasoning behind it.
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