In June 2021, I wrote an in-depth guide about sorting arrays in JavaScript. It's still one of the best resources to go through. It covers a wide range of the following topics: → Sorting Arrays Alphabetically → Sorting Strings with Non-ASCII Characters → Sorting Array Elements Numerically → ... Provided examples and use cases. Link in the comments. --- ♻️ If you liked it, let others know! #js #javascript #array #sorting
JavaScript Array Sorting Guide: Alphabetical, Numerical, and More
More Relevant Posts
-
If you think semicolons don’t matter in JavaScript…? Click “more” before you scroll ... Skipping semicolons feels harmless… 👀 Until this happens 👇 const arr = [1, 2, 3] (function () { console.log("Hello 👋") })() 👉 Error: arr is not a function 😳 👉 Why? JavaScript thinks you're calling the array as a function Because there’s no semicolon before the IIFE 👉 Fix: const arr = [1, 2, 3]; 👉 Small symbol… big problem 😬 This is due to Automatic Semicolon Insertion (ASI) ⚡ Follow for more simple dev concepts 🚀 #JavaScript #Developers #WebDevelopment #Coding #Debugging #Relatable
To view or add a comment, sign in
-
-
JavaScript Array Methods Every Developer Should Master JavaScript arrays are powerful, if you actually know the methods behind them. From map, filter, and reduce to find, some, and flat, these array methods show up everywhere: Frontend interviews Production code Performance discussions This guide breaks down the most important JavaScript array methods with real-world examples, common mistakes, and when not to use them. If you write JavaScript for a living, these aren’t optional. #JavaScript #JavaScriptArray #JSArrayMethods #frontend #WebDevelopment #Programming #Coding
To view or add a comment, sign in
-
#Most #asked #JavaScript #JS #Programs #Core Reverse a string Check if a string is palindrome Find factorial (iterative & recursive) Fibonacci series Find largest/smallest number in array Remove duplicates from array Count vowels and consonants Check if two strings are anagrams Find missing number in array Find sum of elements in array #Array & #StringBased Flatten nested array Find second largest number Sort array without built-in methods Rotate array (left/right) Find intersection of two arrays Find union of two arrays Chunk array into smaller arrays Remove falsy values from array Find frequency of elements Longest word in string
To view or add a comment, sign in
-
Solved the classic Valid Parentheses problem using a stack-based approach in JavaScript. Key idea: Use a stack to track opening brackets and a hash map to validate closing pairs efficiently in O(1). Approach: Push opening brackets (, {, [ onto the stack On encountering a closing bracket, check: If stack is empty → invalid If top of stack doesn’t match → invalid At the end, stack must be empty for a valid string Optimized with: Single pass traversal → O(n) time complexity Stack space → O(n) worst case This problem reinforces a fundamental pattern: Stack + Mapping = Efficient bracket validation #JavaScript #DataStructures #Algorithms #Stack #CodingInterview #LeetCode
To view or add a comment, sign in
-
-
Problem: Palindrome Linked List ✔️ All test cases passed ✔️ Runtime: 141 ms My Approach (Simple & Intuitive): Instead of modifying the linked list or using complex pointer tricks, I went with a straightforward idea: 👉 Traverse the linked list once 👉 Build two strings: 1. One in forward order 2. One in reverse order 👉 Compare both strings If they match → it's a palindrome ✅ Yes, it's not the most optimal in terms of space, but it gets the job done cleanly. Complexity: Time: O(n) Space: O(n) #LeetCode #DSA #LinkedList #Algorithms #JavaScript #ProblemSolving #CodingJourney #LearnInPublic
To view or add a comment, sign in
-
-
JavaScript's type coercion can lead to some truly surprising results, like [] == false evaluating to true due to how JS converts types behind the scenes. Check out this hilarious meme that captures the chaos perfectly—ever seen NaN === NaN return false? 😲 These quirks highlight why grasping truthy/falsy values (falsy: false, 0, "", null, undefined, NaN) and loose equality (==) is essential for solid coding. Pro tip: Always use strict equality (===) to avoid headaches! 🚀 What's your wildest JS coercion story? Share below! 👇 #JavaScript #WebDevelopment #Coding #TypeCoercion #Frontend #ProgrammingHumor #DevLife #LearnJS
To view or add a comment, sign in
-
-
One of my favorite JavaScript one-liners: filter(Boolean). Filtering out falsy values from an array meant chaining conditions and hoping I hadn't missed an edge case. When you pass Boolean as a callback to .filter(), JavaScript calls Boolean(item) on every element. Anything falsy - null, undefined, 0, ", false, NaN - gets removed. What you're left with is a clean array of only meaningful values. It's not just about writing less code. It's about communicating intent clearly. This pattern shines especially in real-world scenarios: cleaning up APl responses, processing user input, or combining .map) and.filter) to transform and sanitize data in a single chain. #JavaScript #WebDevelopment #SoftwareEngineering #CleanCode #Frontend #Programming #JS #CodeQuality #TechTips #Developer
To view or add a comment, sign in
-
-
"Complete Guide to the useEffect Hook in React. This clean infographic breaks down everything you need to know about useEffect: Purpose: Running side effects after render (data fetching, subscriptions, DOM manipulation, timers) Syntax: Full code example with side effect and cleanup function Dependency Array: Detailed explanation of [], no array, and [dep1, dep2] behaviors Cleanup Function: How to prevent memory leaks Common Mistakes: Infinite loops, missing dependencies, and stale closures Best Practices: Keeping effects focused and using custom hooks for complex logic An essential visual cheat sheet for mastering side effects in functional React components." #React #useEffect #ReactHooks #ReactJS #JavaScript #FrontendDevelopment #WebDevelopment #ReactTutorial #Coding #Programming #SideEffects #CleanupFunction #DependencyArray #ReactCheatSheet #LearnReact #DeveloperLife #CodeSnippets
To view or add a comment, sign in
-
-
Built and shipped my Learning Journal 🛠️ This started as a simple project, but quickly turned into a deep dive into layout systems, responsive design, and structuring reusable components in JavaScript. A lot of small details, but that’s where the real learning happens. Check it out 👇 🔗https://lnkd.in/eZSzCYUw #CodingJourney #FrontendDevelopment #JavaScript #BuildInPublic #Scrimba
To view or add a comment, sign in
-
"I’m just going to say it: JavaScript Promises are hard. 🙃 I thought I had a handle on asynchronous code, but then came .then(), .catch(), and the logic of resolve vs reject. It’s one of those topics where you think you’ve got it, and then one unhandled rejection reminds you that you don't. Learning to code isn't always 'eureka' moments; sometimes it's just sitting with the frustration until it clicks. To my fellow devs—what was the one JS concept that finally made the lightbulb go off for you? #Javascript #WebDevelopment #CodingLife #LearnToCode"
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
🔗 https://www.hassib.co/blog/how-to-sort-arrays-in-javascript