array.sort() Does Not Simply Sort Numbers in JavaScript
Explains why JavaScript's array.sort() doesn't sort numbers numerically by default and how to fix it using a comparator function.
Dmitri Pavlutin is a Senior Frontend Developer with 10+ years of experience, specializing in JavaScript, TypeScript, React, and Vue.js. He shares practical tutorials and insights on modern frontend development, UI/UX, and application architecture.
176 articles from this blog
Explains why JavaScript's array.sort() doesn't sort numbers numerically by default and how to fix it using a comparator function.
A guide to identifying and fixing common infinite loop issues when using the React useEffect hook in your components.
Introduces JavaScript's new array.at(index) method, highlighting its ability to access array elements using negative indices.
Explains the technical distinction between DOM nodes and elements in web development, detailing node types and their hierarchy.
Explains why immediately resolved Promise callbacks execute before setTimeout(callback, 0) due to JavaScript's microtask (job) queue vs. macrotask queue.
Explains JavaScript callback functions, including synchronous and asynchronous types, with practical examples for developers.
Explains how React's useState hook updates state asynchronously and demonstrates correct patterns for consecutive updates.
A guide to common pitfalls when using React Hooks, including conditional invocation and stale closures, with practical solutions.
Learn 5 best practices for writing clean, maintainable, and readable JavaScript variables, focusing on const/let, scope, and naming.
Explains how to use JavaScript's typeof and instanceof operators for type checking, including quirks like typeof null.
Explains three methods to check if a variable is defined in JavaScript, covering typeof, try-catch, and global object checks.
A React tutorial on handling forms: accessing input values, implementing validation, and managing form submission using controlled components.
Explains the concept of prototypal inheritance in JavaScript, covering prototypes, own vs. inherited properties, and practical examples.
A guide to implementing configurable timeouts for JavaScript fetch() requests using AbortController and setTimeout.
A beginner's guide to learning JavaScript fundamentals, covering study methods, recommended resources, and motivation tips.
A beginner-friendly guide explaining the React useEffect hook, covering side-effects, dependencies, lifecycle, and practical examples like data fetching.
Explains JavaScript iterators, iterables, and how to use them with for...of loops, spread operators, and other consumers.
A guide to implementing controlled inputs in React using hooks, covering single and multiple input management.
A comprehensive guide to the null value in JavaScript, covering its meaning, detection, differences from undefined, and usage pitfalls.
A guide to using the JavaScript Fetch API with async/await syntax, covering data fetching, error handling, and request cancellation.