📝 How does map.entries() work?
The Map.entries() function returns a new iterator that contains [key, value] arrays for each pair of elements in the map object, in the order they were added to the object.
This method can be useful when you want to iterate over all the elements of a Map object and perform some action on each pair.
Map.entries() returns an iterator, not an array, for an array in the end, you should use other methods
The Map.entries() function returns a new iterator that contains [key, value] arrays for each pair of elements in the map object, in the order they were added to the object.
This method can be useful when you want to iterate over all the elements of a Map object and perform some action on each pair.
Map.entries() returns an iterator, not an array, for an array in the end, you should use other methods
👍5❤3
🖥 How does Object.create() work?
The Object.create method creates a new object with the specified prototype and properties.
It takes two arguments: the first is an object that will be the prototype for the new object.
The second is an optional object containing the properties and their descriptors that will be added to the new object.
If the first argument is not passed or is null, the new object will be created with Object.prototype as the prototype.
The Object.create method creates a new object with the specified prototype and properties.
It takes two arguments: the first is an object that will be the prototype for the new object.
The second is an optional object containing the properties and their descriptors that will be added to the new object.
If the first argument is not passed or is null, the new object will be created with Object.prototype as the prototype.
👍8❤2🔥1
💻 What are React Server Components? Understanding the Future of React Apps
React Server Components (RSC) is the latest and perhaps the most significant change since React hooks. Notably, big voices in the React community have endorsed RSCs, highlighting their importance in the future of React. However, this change has met with mixed reactions within the community
React Server Components (RSC) is the latest and perhaps the most significant change since React hooks. Notably, big voices in the React community have endorsed RSCs, highlighting their importance in the future of React. However, this change has met with mixed reactions within the community
❤8👍2
🏄 CSS Grid Areas
CSS Grid support has been widely available since March 2017 in all major browsers. Yet, here we are in 2024, and I still see few people using the grid template areas feature.
It’s no surprise that many avoid template areas as making sense of the grid is challenging enough. In this interactive article, I aim to shed light on this feature and, hopefully, convince you to use it more often. Once you see the simplicity and power of template areas, you may reach for them much more frequently.
CSS Grid support has been widely available since March 2017 in all major browsers. Yet, here we are in 2024, and I still see few people using the grid template areas feature.
It’s no surprise that many avoid template areas as making sense of the grid is challenging enough. In this interactive article, I aim to shed light on this feature and, hopefully, convince you to use it more often. Once you see the simplicity and power of template areas, you may reach for them much more frequently.
👍10❤3
react-19-cheat-sheet.pdf
1.4 MB
📝 React 19 Cheat Sheet
This is part cheat sheet, part quick reminder of some of the new features in React 19 with simple code examples.
This is part cheat sheet, part quick reminder of some of the new features in React 19 with simple code examples.
❤8🔥3👍2
AbortController is more than you think
AbortController is a JavaScript API for creating an object with two properties, a signal and an abort() method, that can be used to abort tasks.
📌 Usage:
🟠You can use AbortController to abort HTTP requests via fetch().
🟠You can add event handlers using AbortSignal, which will allow you to automatically unsubscribe from events.
🟠AbortController also supports aborting streams.
📌 Advanced Features:
🟠Use AbortSignal.timeout() for automatic cancellation based on a timer.
🟠AbortSignal.any() allows you to combine multiple signals into one, making the API even more flexible.
🟠Cancellation error handling: When calling abort(), you can pass a cancellation reason, allowing for more flexible handling of canceled operations.
AbortController is a JavaScript API for creating an object with two properties, a signal and an abort() method, that can be used to abort tasks.
📌 Usage:
🟠You can use AbortController to abort HTTP requests via fetch().
🟠You can add event handlers using AbortSignal, which will allow you to automatically unsubscribe from events.
🟠AbortController also supports aborting streams.
📌 Advanced Features:
🟠Use AbortSignal.timeout() for automatic cancellation based on a timer.
🟠AbortSignal.any() allows you to combine multiple signals into one, making the API even more flexible.
🟠Cancellation error handling: When calling abort(), you can pass a cancellation reason, allowing for more flexible handling of canceled operations.
👍6❤1
How to Annul Promises in JavaScript
In JavaScript, you might already know how to cancel a request: you can use xhr.abort() for XHR and signal for fetch. But how do you cancel a regular Promise?
Currently, JavaScript's Promise does not natively provide an API to cancel a regular Promise. So, what we’ll discuss next is how to discard/ignore the result of a Promise.
In JavaScript, you might already know how to cancel a request: you can use xhr.abort() for XHR and signal for fetch. But how do you cancel a regular Promise?
Currently, JavaScript's Promise does not natively provide an API to cancel a regular Promise. So, what we’ll discuss next is how to discard/ignore the result of a Promise.
👍7❤2