Day 24 of #30DaysOfJavaScript on LeetCode Today’s Challenge: 2724 - Sort By Today’s problem was about creating a custom sorting utility using a function as the sorting key similar to how higher-order sorting works in real-world JavaScript applications. Here’s my solution: var sortBy = function(arr, fn) { return arr.sort((a, b) => fn(a) - fn(b)); }; This challenge reinforced how powerful higher-order functions are when writing clean and expressive JavaScript code. 🔗 Try the problem here: https://lnkd.in/g6WC5mu7 #JavaScript #LeetCode #CodingChallenge #LearningJourney #WebDevelopment #Developers #FrontEndDevelopment #30DaysOfCode #30DaysOfJavaScript
JavaScript Custom Sorting Utility with Higher-Order Functions
More Relevant Posts
-
JavaScript Hoisting — explained simply 🧠⬆️ Hoisting is one of the most confusing JavaScript topics, but the idea is actually very simple. Before executing code, JavaScript: ✔ Scans the file ✔ Allocates memory for variables and functions Important points: • Function declarations are fully hoisted • var is hoisted but initialized as undefined • let & const are hoisted but not accessible (TDZ) Simple rule to remember: Hoisting moves declarations to the top, not values. Understanding hoisting helps avoid “undefined” and reference errors 🚀 #javascript #frontenddeveloper #webdevelopment #coding #learningjavascript #reactjs #softwareengineering
To view or add a comment, sign in
-
-
The `this` keyword in JavaScript — explained simply 🧠 `this` confuses many developers at first. The key is: it depends on HOW a function is called. Normal Function 👇 • `this` refers to the object that calls the function • Value is dynamic Arrow Function 👇 • `this` does NOT have its own context • It takes `this` from the parent scope Simple rule to remember: Normal function → its own `this` Arrow function → borrows `this` This is why arrow functions are commonly used in: ✔ Callbacks ✔ React components ✔ Event handlers (carefully) Once this clicks, many bugs disappear 🚀 #javascript #frontenddeveloper #webdevelopment #coding #learningjavascript #reactjs #softwareengineering
To view or add a comment, sign in
-
-
🚀 Day 847 of #900DaysOfCode ✨ Master JavaScript Arrays Like a Pro Arrays are at the heart of JavaScript — and the more powerful your array skills are, the faster and cleaner your code becomes. In today’s post, I’ve shared 20 essential JavaScript array methods that every developer should know. Explained in a simple, visual, and beginner-friendly way, these methods will help you write more efficient logic and solve problems with confidence. If you want to become truly unstoppable with JS arrays, this post is for you. 👇 Which array method do you use the most? Tell me in the comments! #Day847 #learningoftheday #900daysofcodingchallenge #JavaScript #WebDevelopment #FrontendDevelopment #CodingCommunity #LearnInPublic
To view or add a comment, sign in
-
👀 This JavaScript Code Looks Normal… But the Output Isn’t Most people read this and say: “easy” But many get the output wrong 👀 CODE : let arr = [1, 2, 3]; console.log(arr.length); arr.length = 0; console.log(arr); console.log(arr.length); No loops. No functions. Just one property: length. Still… this surprises a lot of developers 🧠 Why this question matters Helps you understand how arrays really work Shows that length is not just a number Very common interview + real debugging scenario Looks simple but tests real understanding 💬 Your Turn Comment your answers like this 👇 Line 1 → ? Line 2 → ? Line 3 → ? Try answering without running the code 🤓 I will post the correct output + simple explanation in the evening 📌 Note: This is to understand JavaScript behavior, not to encourage confusing code. #JavaScript #FrontendDevelopment #LearnJS #CodingInterview #TechWithVeera #WebDevelopment #100DaysOfCode
To view or add a comment, sign in
-
-
👀 This JavaScript Code Looks Harmless… But the Output Shocks Many Most people glance at this and say “easy” But the result surprises a lot of developers 👀 let a = []; let b = []; console.log(a == b); console.log(a === b); let c = a; console.log(a === c); No loops. No async code. Just arrays and comparisons. Still… many answers go wrong 🤯 🧠 Why this question matters Tests reference vs value understanding Very common interview question Helps avoid real bugs when comparing arrays/objects Looks simple but checks deep basics 💬 Your Turn Comment your answers like this 👇 Line 1 → ? Line 2 → ? Line 3 → ? Try answering without running the code 🤓 I will post the correct output + simple explanation in the evening. 📌 Note: This is to understand JavaScript behavior, not to suggest comparing arrays directly in production. #JavaScript #FrontendDevelopment #LearnJS #CodingInterview #TechWithVeera #WebDevelopment #100DaysOfCode
To view or add a comment, sign in
-
-
🧠 Shortcuts don’t break JavaScript. Misunderstanding fundamentals does. I tried using throw new Error() inside a ternary operator, expecting it to behave like an if/else. ❌ Didn’t work. 🧠 The reason (important): • throw is a statement, not an expression • Ternary operators only accept expressions Small syntax rule. Big “aha” moment. 💡 What this reinforces: ✔️ Fundamentals matter more than clever tricks ✔️ JavaScript rewards clarity over shortcuts ✔️ Tiny misunderstandings can cause long debugging sessions These are the kinds of details that separate code that runs from code that’s reliable. 👀 Your turn: What’s the smallest JavaScript mistake that once wasted the most time for you? 💬 Drop it in the comments let’s learn from each other. 📩 And if you’re building or reviewing a Node.js/JavaScript codebase and want it clean, predictable, and production-ready feel free to DM me. #JavaScript #NodeJS #WebDevelopment #SoftwareEngineering #CodingLife #DeveloperLearning #CleanCode #Debugging #ProgrammingTips #TechCommunity #BuildInPublic
To view or add a comment, sign in
-
-
**JavaScript Polyfills – Explained with Real Examples 🚀** Not every browser understands modern JavaScript. And that’s where **polyfills** come into play. 👉 A polyfill is a fallback implementation that makes modern JS features work in older browsers. In this post: ✔ `String.includes()` ✔ `Array.filter()` ✔ `Array.map()` ✔ `Array.reduce()` All recreated manually to understand **how JavaScript really works under the hood.** Writing code is easy. Writing **browser-compatible, reliable code** is what makes you a better developer. Learning fundamentals > blindly using frameworks. 💡 #JavaScript #Polyfills #FrontendDevelopment #WebDevelopment #LearningInPublic #DeveloperJourney
To view or add a comment, sign in
-
-
🚀 Day 851 of #900DaysOfCode ✨ Hoisting in JavaScript JavaScript behaves in some unique ways, and one of the concepts that often confuses beginners (and even experienced devs) is hoisting. In today’s post, I’ve explained hoisting in a clean, simple, and visual way — helping you understand how JS treats variables and functions before the code actually runs. If you’ve ever wondered why certain values become `undefined` or how function declarations work behind the scenes, this post will clear it all up. If you want to write more predictable and bug-free JS, this one is for you. 👇 What’s one thing about hoisting that surprised you the first time you learned it? Share in the comments! #Day851 #learningoftheday #900daysofcodingchallenge #FrontendDevelopment #WebDevelopment #JavaScript #React #CodingCommunity #InterviewPrep
To view or add a comment, sign in
-
Hoisting isn’t magic — it’s JavaScript doing exactly what it was designed to do. ⚙️ Understanding how variables and functions are treated before execution will level up your debugging and code clarity instantly. Solid breakdown in this carousel 👏 Worth saving if you work with JS daily. Credits to Shivam Dhyani for the original post 🙌 #JavaScript #ReactDeveloper #Frontend #CodingTips #WebDev #DevCommunity
🚀 Day 851 of #900DaysOfCode ✨ Hoisting in JavaScript JavaScript behaves in some unique ways, and one of the concepts that often confuses beginners (and even experienced devs) is hoisting. In today’s post, I’ve explained hoisting in a clean, simple, and visual way — helping you understand how JS treats variables and functions before the code actually runs. If you’ve ever wondered why certain values become `undefined` or how function declarations work behind the scenes, this post will clear it all up. If you want to write more predictable and bug-free JS, this one is for you. 👇 What’s one thing about hoisting that surprised you the first time you learned it? Share in the comments! #Day851 #learningoftheday #900daysofcodingchallenge #FrontendDevelopment #WebDevelopment #JavaScript #React #CodingCommunity #InterviewPrep
To view or add a comment, sign in
-
null vs undefined in JavaScript 🧠 These two confuse almost every beginner. But the difference is actually simple. undefined 👇 • JavaScript assigns it automatically • Variable is declared but not given a value • Means “value not available yet” null 👇 • Assigned intentionally by the developer • Means “empty on purpose” • Used to clear or reset a value Simple way to remember: undefined → JS did it null → YOU did it Understanding this helps avoid unexpected bugs and confusion in real projects 🚀 #javascript #frontenddeveloper #webdevelopment #coding #learningjavascript #reactjs #softwareengineering
To view or add a comment, sign in
-
Explore related topics
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