𝗟𝗲𝘁'𝘀 𝘁𝗮𝗹𝗸 𝗮𝗯𝗼𝘂𝘁 𝗔𝗹𝗴𝗼𝗿𝗶𝘁𝗵𝗺𝘀! Let's start our series with the most familiar topic - 𝗕𝗶𝗴 𝗢. The concept of Big O describes how the 𝗿𝘂𝗻𝗻𝗶𝗻𝗴 𝘁𝗶𝗺𝗲 𝗼𝗿 𝗺𝗲𝗺𝗼𝗿𝘆 𝗰𝗼𝗻𝘀𝘂𝗺𝗽𝘁𝗶𝗼𝗻 of an algorithm increases as its input grows. That is, it is a way of measuring the efficiency of code in terms of the size of the input, regardless of the computer or the language in which it is written. We've all heard of the terms O(n), O(1) or O(n²) and didn't exactly understand what they meant. 💠𝘖(1) - 𝘊𝘰𝘯𝘴𝘵𝘢𝘯𝘵 𝘛𝘪𝘮𝘦 The running time does not change even if the input size increases. For example: Direct access to an element in an array by index (arr[0]). It doesn't matter if the array has 10 elements or a million - the operation will take the same time. 💠𝘖(𝘯) - 𝘓𝘪𝘯𝘦𝘢𝘳 𝘛𝘪𝘮𝘦 The running time increases at the same rate as the input. For example: Looping through all elements of an array. If we increase the amount of data by 2 times - the running time will also increase by about 2 times. 💠𝘖(𝘯2) - 𝘘𝘶𝘢𝘥𝘳𝘢𝘵𝘪𝘤 𝘛𝘪𝘮𝘦 The running time increases by the square of the input size. For example: A loop within a loop that goes through each element in front of every other element. If we increase the input by 2 times - the running time will increase by 4 times. #algorithms #BigO #javaScript #Developres #fullStack
Understanding Big O Notation for Algorithm Efficiency
More Relevant Posts
-
Partition Array by Predicate (Fast & Simple) Need to split data into two buckets—approved vs rejected, in-stock vs out-of-stock, active vs inactive? Use a tiny partition helper to divide an array into [pass, fail] in one sweep. It’s fast, readable, and perfect for real-world lists and filters. Why it’s production-ready Single pass over data (O(n)) Preserves original order in both buckets Works with primitives or objects (any predicate) Drop it into your toolkit and keep your array logic clean. ⚡ #JavaScript #VanillaJS #Arrays #CleanCode #WebDev
To view or add a comment, sign in
-
-
📒 No more writing custom logic for set math — JS now supports: union() intersection() difference() isSubsetOf() isDisjointFrom() All natively on Set.prototype 💪 🧠 Example: const a = new Set([1, 2, 3]); const b = new Set([3, 4, 5]); a.union(b); // → Set {1, 2, 3, 4, 5} a.intersection(b); // → Set {3} a.difference(b); // → Set {1, 2} a.isSubsetOf(b); // → false a.isDisjointFrom(b); // → false 💡 Why it’s cool: No external libraries. No hacks. Just clean, readable, math-like operations built right into JavaScript. 💬 Which one will you use first — union() or intersection()? #JavaScript #ES2025 #WebDevelopment #CodingTips #Developers
To view or add a comment, sign in
-
🔍 Day 168 of #200DaysOfCode Today, I focused on filtering specific values from an array — in this case, extracting only odd numbers using basic loop logic in JavaScript. ✔ This exercise reinforces how important condition checking is while working with data. ✔ Instead of using advanced built-in methods like .filter(), I wrote the logic manually — which improves clarity and confidence in how loops operate. ✅ What I practiced today: • Iterating through arrays • Checking conditions using modulo % • Selectively pushing results into a new array • Handling edge cases (like when no odd numbers exist) 🌱 Filtering is a skill that scales — from small number lists to large datasets powering real-world apps. Strong fundamentals → Strong code → Strong developer 💪 #JavaScript #168DaysOfCode #CodingChallenge #BackToBasics #LearnInPublic #ProblemSolving #WebDevelopment #DeveloperMindset #LogicBuilding
To view or add a comment, sign in
-
-
Day 12 of JS series - by Rohit Negi What I learned: ✅ forEach() – Iterates over every element in an array. ✅ filter() – Filters elements from an array based on a specific condition and returns a new array. ✅ map() – Transforms each element of an array and returns a new array. ✅ reduce() – Reduces an array to a single value (of any data type). ✅ Set – A data structure that stores unique values. ✅ Map – A data structure that stores key-value pairs, where both keys and values can be of any data type. #LearnInPublic #JavaScript #WebDevelopment
To view or add a comment, sign in
-
-
𝐄𝐯𝐞𝐫 𝐰𝐨𝐧𝐝𝐞𝐫𝐞𝐝 𝐰𝐡𝐞𝐫𝐞 𝐲𝐨𝐮𝐫 𝐉𝐚𝐯𝐚𝐒𝐜𝐫𝐢𝐩𝐭 𝐯𝐚𝐫𝐢𝐚𝐛𝐥𝐞𝐬 𝐚𝐜𝐭𝐮𝐚𝐥𝐥𝐲 𝐥𝐢𝐯𝐞? Let’s make it super simple. Imagine your brain has two spaces — a tiny desk for quick tasks and a big cupboard for storing bulky stuff. That’s exactly how JavaScript manages memory 👇 🧠 𝕊𝕥𝕒𝕔𝕜 𝕄𝕖𝕞𝕠𝕣𝕪 = The Desk This is where small, quick items go — numbers, strings, booleans. It’s fast, neat, and clears up right after you’re done. 𝚕𝚎𝚝 𝚗𝚊𝚖𝚎 = "𝙰𝚗𝚊𝚜"; 𝚕𝚎𝚝 𝚊𝚐𝚎 = 𝟸𝟼; Both variables fit nicely on the stack. 📦 ℍ𝕖𝕒𝕡 𝕄𝕖𝕞𝕠𝕣𝕪 = The Cupboard This is for bigger and more complex things — objects, arrays, functions. It takes more space and time to access. 𝚕𝚎𝚝 𝚞𝚜𝚎𝚛 = { 𝚗𝚊𝚖𝚎: "𝙰𝚗𝚊𝚜", 𝚊𝚐𝚎: 𝟸𝟼 }; The object is stored in the heap, but a reference to it sits in the stack. ⚖️ In short: Stack → fast, organized, for simple data Heap → flexible, powerful, for dynamic data Understanding this helps you write cleaner code, avoid memory leaks, and truly know what happens “under the hood.” #JavaScript #CodingTips #WebDevelopment #LearnInPublic #Frontend #AnasKhan
To view or add a comment, sign in
-
-
Every time you write for (...) if (...) {...} you’re telling the computer how to work. Always Ask: “What’s the transformation?” and reach for .map(), .filter(), .reduce(). Stop managing steps. Start shaping data flows. Below is a code that lets us chunk by predicate. For more insights check this book https://lnkd.in/d4Ft9KDX #Javascript #CleanCode #FunctionalProgramming
To view or add a comment, sign in
-
-
🚫 The Error That Every Frontend Developer Meets Once I was just running a local HTML file when Chrome threw this at me: ERROR X __ Access to script at 'file:///C:/...' from origin 'null' has been blocked by CORS policy:Cross origin requests are only supported for protocol schemes:chrome, chrome-extension, chrome-untrusted, data, http, https, isolated-app. At first, it looked confusing — why would Chrome block my own files? 🤔 The answer: CORS (Cross-Origin Resource Sharing). When you open an HTML file directly using file://, every local file is treated as a different "origin," and browsers block such access for security reasons. The easiest and most elegant fix? Run your own local web server with one simple Python command: Bash python -m http.server 8000 Here's what happens step by step 👇 1️⃣ python → runs your Python interpreter 2️⃣ -m → tells it to use a built-in module 3️⃣ http.server → launches a mini web server right in your current folder 4️⃣ 8000 → the port number you'll open in your browser Then just visit 👉 http://localhost:8000 ✅ No more CORS errors ✅ Your HTML, CSS, and JS load like they would on a real site ✅ It works instantly — no installs, no config Sometimes, the simplest command hides the most powerful solution. ⚡ #AI #LearningByDoing #HPC #Automation #Knowledge #Innovation #Motivation
To view or add a comment, sign in
-
-
We’ve all been there debugging a perfectly fine API response... only to realize your data is failing validation because of a few invisible spaces. These trailing spaces can silently break string comparisons, UI bindings, and even backend validations. So, I wrote a simple recursive utility in JavaScript to clean them deeply. 🧹 𝗪𝗼𝗿𝗸𝘀 𝗳𝗼𝗿: Nested objects Arrays Deeply nested strings 𝗜𝗻𝘁𝗲𝗿𝘃𝗶𝗲𝘄𝗲𝗿𝘀 𝗹𝗼𝘃𝗲 𝗮𝘀𝗸𝗶𝗻𝗴 𝗮𝗯𝗼𝘂𝘁: Recursion Object traversal Data normalization or deep cloning This question can easily appear as: “Write a function to remove spaces from all string values in a nested object.” #JavaScript #WebDevelopment #CodingTips #Frontend
To view or add a comment, sign in
-
-
You’re right to be shocked, JavaScript can actually outperform Rust in certain cases. JS may look lightweight, but behind the scenes it’s running with C++-level horsepower, giving it bursts of speed you wouldn’t expect. Rust, on the other hand, stays focused on safety and correctness… even if that means slowing down a bit during parsing. JSON.parse is a native, highly-optimized C++ fast path inside modern JS engines (V8/SpiderMonkey/JSC). It can use SIMD and clever allocation strategies to blast through plain JSON into dynamic objects. Serde is doing more work by design: strong typing, strict validation, custom field rules, and often building real Rust structs (not just loose maps). Safety & correctness add overhead. Many “benchmarks” compare dynamic JS objects vs typed Rust structs = apples vs oranges. If Serde parses into an untyped Value, timings tighten a lot. When JS wins Parse → inspect a few fields → forward/store. Short-lived scripts and serverless handlers where startup and GC behavior are favorable. When Rust wins Huge payloads, steady throughput, low memory overhead, and typed contracts. Use streaming deserialization, borrowed strings, or simd-accelerated parsers in Rust to fly. Reality check I/O, compression, and DB calls usually dwarf parse time. Benchmark your workload before making language bets. Your turn: What’s the fastest real-world JSON path you’ve shipped—and in which language?👇 #JavaScript #Rust #Serde #V8 #WebPerformance #Backend #Engineering
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