![]() Both of these features rely on garbage collector implementation that varies based on engine and engine’s version. const API = "" Promise.any([ fetch(`$) registry.register(obj, "ECMAScript 2021") // perform some action that triggers garbage collector on obj // The ECMAScript 2021 object has been garbage collected.īe careful though - we should avoid using them as per proposal’s author recommendation. Use Promise.any when you want to handle the first promise that fulfils. The Promise.any joins the list of Promise combinators in this year’s specification. const string = "it-is-just-a-test" // instead of doing this string.replace(/-/g, "_") // "it_is_just_a_test" // in ES2021 we can do string.replaceAll("-", "_") // "it_is_just_a_test" Promise.any by Mathias Bynens, Kevin Gibbons and Sergey Rubanov # The popularity of “How to replace all occurrences of a string in Javascript?” thread on StackOverflow proves this feature’s need in the language. The by Peter Marshall, Jakob Gruber and Mathias Bynens simplify this. To replace all string occurrences, we need to use a combination of and global regexp. by Peter Marshall, Jakob Gruber and Mathias Bynens #
0 Comments
Leave a Reply. |