🚀 Day 11/30 – Javascript interview series Local Storage vs Session Storage 🔥 Ever wondered where your browser stores data without a database? 🤔 Let’s break down Local Storage vs Session Storage in JavaScript 👇 💡 Local Storage ✔ Stores data with NO expiration time ✔ Data persists even after browser is closed ✔ Shared across tabs (same origin) 💡 Session Storage ✔ Stores data only for one session ✔ Data is cleared when the tab is closed ✔ Not shared between tabs ⚡ Syntax: 👉 localStorage.setItem("key", "value") 👉 sessionStorage.setItem("key", "value") 📌 Key Difference: Local Storage = Long-term storage 🗄️ Session Storage = Temporary storage ⏳ 🧠 Use Cases: ✔ Local Storage → Remember user preferences, themes ✔ Session Storage → Form data, temporary session info 🔥 Interview Questions: ❓ Difference between localStorage and sessionStorage? ❓ Storage limit? ❓ Is it secure to store sensitive data? (Hint: ❌ No) #javascript #webdevelopment #frontenddeveloper #reactjs #100daysofcode #interviewpreparation
Local Storage vs Session Storage in JavaScript
More Relevant Posts
-
Great insight Rushikesh Chavhan You can also add cookies and indexDB. IndexDB: Stores large structured data (MBs/GBs) Works like a NoSQL DB Used for: Offline apps Caching large data Complex data storage Cookies: Small pieces of data stored in the browse Used for: Authentication (session ID, tokens) Tracking / analytics
Front-End Developer @ Laminaar Aviation Infotech | 3 Years Experience | HTML | CSS | JavaScript | React.js | Nodejs | Web Developer | PG-DAC.
🚀 Day 11/30 – Javascript interview series Local Storage vs Session Storage 🔥 Ever wondered where your browser stores data without a database? 🤔 Let’s break down Local Storage vs Session Storage in JavaScript 👇 💡 Local Storage ✔ Stores data with NO expiration time ✔ Data persists even after browser is closed ✔ Shared across tabs (same origin) 💡 Session Storage ✔ Stores data only for one session ✔ Data is cleared when the tab is closed ✔ Not shared between tabs ⚡ Syntax: 👉 localStorage.setItem("key", "value") 👉 sessionStorage.setItem("key", "value") 📌 Key Difference: Local Storage = Long-term storage 🗄️ Session Storage = Temporary storage ⏳ 🧠 Use Cases: ✔ Local Storage → Remember user preferences, themes ✔ Session Storage → Form data, temporary session info 🔥 Interview Questions: ❓ Difference between localStorage and sessionStorage? ❓ Storage limit? ❓ Is it secure to store sensitive data? (Hint: ❌ No) #javascript #webdevelopment #frontenddeveloper #reactjs #100daysofcode #interviewpreparation
To view or add a comment, sign in
-
Understanding JavaScript Data Types . JavaScript is the backbone of modern web development, but even experienced developers sometimes trip up on the nuances of Data Types. Whether you're optimizing performance or debugging complex logic, knowing how JS handles memory is key. In this infographic, I’ve broken down the two main categories: ✅ Primitive Types: The building blocks (Number, String, Boolean, etc.) that are immutable and stored by value. ✅ Non-Primitive Types: Complex structures (Objects, Arrays, Functions) that are mutable and stored by reference. Understanding these is the first step toward writing cleaner, more efficient code. Which Data Type do you find yourself using most in your current project? Let’s discuss in the comments! 👇 #JavaScript #WebDevelopment #CodingTips #SoftwareEngineering #TechCommunity #JSBasics #Programming
To view or add a comment, sign in
-
-
🚀 Harness the Power of Arrays in JavaScript! 🚀 Arrays are like containers that hold multiple values in a single variable, making data organization and manipulation a breeze in JavaScript. For developers, mastering arrays is crucial for efficient data handling and accessing elements for various operations. Here's a simple breakdown to work with arrays: 1️⃣ Declare an array using square brackets: let myArray = [value1, value2, value3]; 2️⃣ Access elements using their index: let thirdElement = myArray[2]; 3️⃣ Add elements using push() method: myArray.push(value4); 4️⃣ Remove elements using pop() method: myArray.pop(); Full code example: ```javascript let myArray = ["apple", "banana", "orange"]; let thirdElement = myArray[2]; myArray.push("grape"); myArray.pop(); ``` Pro tip: Use array methods like map(), filter(), and reduce() for advanced data manipulation tasks efficiently. 🌟 Common mistake to avoid: Forgetting that array indexes start from 0, so the first element is always accessed as myArray[0]. Let's hear from you: What's your favorite array manipulation method in JavaScript? 🤔 🌐 View my full portfolio and more dev resources at tharindunipun.lk #JavaScript #Arrays #DataManipulation #CodeNewbie #WebDevelopment #ProTip #DevTips #CodingIsFun
To view or add a comment, sign in
-
-
One small pattern I really like in JavaScript/TypeScript: return data.items .slice(offset, offset + limit) .map(({ id, firstName, lastName, companyId }) => ({ id, firstName, lastName, companyId, })); Why this is clean: • slice(offset, offset + limit) → handles pagination in a single, readable step • map(...) → transforms data immediately, returning only what’s needed • Object destructuring → avoids repetitive item.id, item.firstName, etc. • No mutations → everything is predictable and functional It’s concise, readable, and does exactly what it needs — nothing more. Sometimes clean code is just about using the right built-in methods. #JavaScript #TypeScript #CleanCode #javascript #remote
To view or add a comment, sign in
-
𝗧𝗵𝗲 𝗨𝗹𝗧𝗶𝗺𝗮𝗧𝗲 𝗚𝗨𝗶𝗱𝗲 𝗧𝗼 𝗔𝗿𝗿𝗮𝗬 𝗙𝗟𝗔𝗧𝗧𝗘𝗡𝗜𝗡𝗚 You work with arrays in JavaScript, but they can get nested and hard to use. That's where array flattening comes in. A nested array is an array inside another array. For example: - `[3, 4]` is a nested array - `[5, [6, 7]]` is a deeply nested array Flattening converts a nested array into a single-level array. You can use array flattening in: - API responses with nested data - Data processing and transformation - Simplifying loops and operations - Preparing data for UI rendering There are different ways to flatten arrays: - Using `flat()` - the easiest way in modern JavaScript - Using recursion - important for interviews - Using a stack - an iterative approach When solving flatten problems, think: - Is recursion needed? - Can I reduce complexity? - What is the depth? - Should I preserve order? Array flattening is a must-know concept in JavaScript. It strengthens recursion skills, improves problem-solving ability, and appears frequently in interviews. Source: https://lnkd.in/grRq_v3K
To view or add a comment, sign in
-
Day 3 of My JavaScript Journey Today, I learned about JavaScript data types and how to define variables. JavaScript has two main types of data: Primitive data types: These include 7 types such as number, string, boolean, null, undefined, symbol, and bigint. Object: used to store more complex data. I also learned three ways to declare variables in JavaScript: • let • const • var One key thing I understood: "const" should be used by default, "let" when the value needs to change, and "var" is mostly outdated. Example: const name = "John"; let age = 20; Key takeaway: Understanding data types and variable declarations is fundamental to writing clean and predictable JavaScript code. #JavaScript #WebDevelopment #LearningInPublic #100DaysOfCode
To view or add a comment, sign in
-
Node.js Worker Threads: True Multi-Threading for Your JavaScript Code Node.js is recognized for its efficient handling of I/O through the Event Loop and the UV_THREADPOOL for system-level tasks. However, when JavaScript code becomes the bottleneck, Worker Threads are essential. 🧠 Core Concepts: - Isolated Execution: Each worker operates in its own V8 instance with separate memory, functioning like lightweight parallel Node.js instances. - True Parallelism: Unlike the Event Loop, which is concurrent, Worker Threads enable parallel execution by utilizing multiple CPU cores. - Message-Based Communication: Workers communicate via postMessage(), ensuring no shared state by default, which reduces race conditions. 🛠 When to use them? - Avoid using Worker Threads for I/O, as the Event Loop is more efficient for that. Instead, utilize them for CPU-bound tasks that could otherwise "freeze" your app: - Heavy Math: Complex calculations or data science in JavaScript. - Data Parsing: Transforming large JSON or CSV files. - Image/Video: Processing buffers or generating reports. Key Takeaway: The Thread Pool manages system tasks, while Worker Threads enhance the performance of your JavaScript code. #NodeJS #Backend #Javascript #WebDev #SoftwareEngineering #Performance
To view or add a comment, sign in
-
-
🚀 JavaScript Full Cheat Sheet Guide — Save Before Your Next Interview! 🧩 Basics & Variables • "let", "const" > "var" • Data types: String, Number, Boolean, Object, Array, Null, Undefined • Type coercion & strict equality ("===") ⚡ Functions & Scope • Function declaration vs Arrow functions • Closures & lexical scope • Higher-order functions power JS 📦 Arrays & Objects • "map()", "filter()", "reduce()" essentials • Destructuring & Spread operator "..." • Object methods & dynamic keys ⏳ Async JavaScript • Event loop fundamentals • Promises & "async/await" • Fetch API for APIs & data handling 🌐 DOM Manipulation • "querySelector()" & event listeners • Event bubbling & delegation • Form handling & validation 🔥 ES6+ Must Know • Template literals • Modules ("import/export") • Optional chaining & nullish coalescing 💡 Reminder: Master concepts → write cleaner, scalable, production-ready JavaScript. Learn more from w3schools.com Source :- Respected owner #JavaScript #FrontendDevelopment #WebDeveloper #CodingTips #SoftwareEngineering
To view or add a comment, sign in
-
🔁 Closures in JavaScript — Not Just Theory, Real Power 🔥 A closure is NOT just a definition It’s how JavaScript enables data privacy & smart functions 👇 🔹 Definition A function that remembers its lexical scope even after execution 🔹 Example function counter() { let count = 0; return function () { count++; return count; }; } const c = counter(); console.log(c()); // 1 console.log(c()); // 2 🔹 What’s happening? 🤔 count is preserved in memory Inner function “closes over” outer scope 🔹 Real Use Cases 💡 Data hiding (private variables) React hooks internally Event handlers 🔹 Common Interview Trap 🚨 Closures inside loops: for (var i = 0; i < 3; i++) { setTimeout(() => console.log(i), 1000); } 👉 Output: 3 3 3 Fix using let ✅ 🔹 Interview Insight 🎯 Say: 👉 “Closures allow function to retain access to variables after execution” ⚠️ Pro Tip: Closures can cause memory leaks if misused Closures = Hidden superpower of JS 💡 #JavaScript #Closures #Frontend #CodingInterview
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
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