How to Make an HTTP Request in JavaScript with Fetch
Use fetch() with async/await for GET and POST requests, handle HTTP errors and timeouts correctly, and learn when XMLHttpRequest still makes sense.
466 posts about JavaScript: questions with answers, tutorials and articles, newest first.
Use fetch() with async/await for GET and POST requests, handle HTTP errors and timeouts correctly, and learn when XMLHttpRequest still makes sense.
Learn to handle JavaScript promises with then, catch, finally and async/await, run several in parallel with Promise.all, and avoid the most common mistakes.
Learn how new Promise works with resolve and reject, how to consume promises with await, and when to use Promise.all, allSettled, race and any.
Callbacks run when a task finishes, while promises represent a future value you can chain. Compare both with examples, async/await and conversion tips.
call invokes a function now with a given this, while bind returns a new function for later. Learn the differences with examples and alternatives.
call() takes arguments one by one, apply() takes them as an array. See examples, modern spread and bind alternatives, and common this pitfalls.
Classes are syntax over JavaScript's prototype chain. Learn how they map to prototypes and which extra rules and features classes add.
Learn every way to add properties to a JavaScript class: public and private fields, constructor assignment, accessors, static members and defineProperty.
Define instance, static, private and accessor methods in an ES2015+ class body, fix this binding, and know when to patch a prototype.
Create a JavaScript constructor with a class or a constructor function, understand what new does, and call super in subclasses.
Use extends and super to inherit from a class in JavaScript. Covers overriding, private fields, static methods, extending Error and when to prefer composition.
Use new with a class constructor to create independent instances that share methods through the prototype. Includes ES2022 private fields and factories.
Create a JavaScript class with class, constructor and methods, then add private fields, static members and inheritance with extends and super.
sort() orders array elements by a comparison rule, while reverse() just flips the current order. Both mutate the array, and ES2023 adds copying versions of each.
slice() returns a copy of part of an array, while splice() removes, replaces or inserts items in the original. Examples, pitfalls and the non-mutating toSpliced().
reduce() processes an array left to right and reduceRight() goes right to left. See when the order matters, with practical examples.
filter() returns a new array of all matching elements, while find() returns the first match or undefined. Compare return values, speed and use cases with examples.
forEach() runs a function for side effects and returns undefined, while map() returns a new transformed array. See examples, pitfalls with async code and when to use each.
Use the spread syntax or concat() to merge two JavaScript arrays into a new one, or push(...) to append in place. This guide compares each approach with examples.
Array.reduce() folds an array into one value. See sum, grouping and flattening examples, the empty array error and when map, filter or flat fit better.