JavaScript Tip 💡 Did you know that you can cancel a fetch request using an AbortController? A common use-case is React: If a component unmounts while a fetch call is awaited, it can be useful to abort the call.

JavaScript

JavaScript Tip 💡 Instead of using find(), or manually searching a list for an occurrence, use the array method some() instead. It’s built for exactly that purpose.

JavaScript

JavaScript Tip 💡 Use the property valueAsNumber to get the numeric number from an input field through an event. Here's an example in React 👇

JavaScript

TypeScript Tip 💡 ️Did you know? You can assign field variables inline using TypeScript ✌️

JavaScript

React Tip 💡 You can use 'React.Children.toArray' to let React automatically assign a key to its children.

React

TypeScript Tip 💡 If you cannot infer or define the type, use 'unknown' instead of 'any'. Using 'unknown' forces you to null-check or narrow the type before using it. 'unknown' is the type-safe counterpart of 'any'.

JavaScript

JavaScript Tip 💡 Did you know that JSON.stringify takes a replacer function as its second argument? You can use it to do filter and replace values when stringifying an object.

JavaScript

JavaScript Tip 💡 You can use Object.entries() to iterate through the properties of an object and access both key and value. No need to do an object lookup for each iteration.

JavaScript

🔹 Promise.allSettled() The Promise.allSettled() method returns a promise that resolves after all of the given promises have either fulfilled or rejected, with an array of objects that each describes the outcome of each promise.

JavaScript

🔹 Promise.all() The Promise.all() method takes an array of promises as an argument and returns a single Promise that resolves to an array of the results of the input promises.

JavaScript

🔹 Promise.race() The Promise.race() method returns a promise that fulfills or rejects as soon as one of the promises in an array fulfills or rejects, with the value or reason from that promise.

JavaScript

🔹 Promise.any() The Promise.any() method takes an array of promises as an argument and, as soon as one of the promises fulfills, returns a single promise that resolves with the value from that promise.

JavaScript

The tweet will be reviewed and posted as soon as possible

{{ newSnippetForm.errors.url[0] }}

{{ newSnippetForm.errors.categories[0] }}