Note ES2024. Eliminates the common pattern of extracting resolve/reject from the Promise constructor. Useful for event-based resolution and deferred patterns.
function* naturals() {
let n = 1;
while (true) yield n++;
}
// Get first 5 even squaresconst result = naturals()
.map(n => n ** 2)
.filter(n => n % 2 === 0)
.take(5)
.toArray();
console.log(result); // [4, 16, 36, 64, 100]
Note ES2025. Chainable lazy operations on any iterator. Unlike array methods, these process elements one at a time, making them memory-efficient for large or infinite sequences.
iterator helperslazy iterationiterator mapiterator filteriterator takeiterator drop
Explicit Resource Management (using)
syntax
using resource = acquireResource();
await using resource = acquireAsyncResource();
example
class TempFile {
constructor(path) {
this.path = path;
console.log(`Created: ${path}`);
}
[Symbol.dispose]() {
console.log(`Cleaned up: ${this.path}`);
}
}
{
using file = new TempFile("/tmp/data.txt");
// Use file here...
} // Automatically calls file[Symbol.dispose]() when block exits
Note TC39 Stage 3 (expected in ES2025/2026). Similar to Python's 'with' or C#'s 'using'. Guarantees cleanup even if an error is thrown. Use Symbol.asyncDispose for async cleanup.
using keywordSymbol.disposeresource managementauto cleanupdisposable
RegExp v Flag (Unicode Sets)
syntax
/pattern/v
example
// Match any emoji using Unicode propertyconst emojiPattern = /\p{Emoji_Presentation}/v;
console.log(emojiPattern.test("hello")); // false
console.log(emojiPattern.test("hi [U+D83D][U+DC4B]")); // true// Set operations in character classesconst greekLetters = /[\p{Script=Greek}&&\p{Letter}]/v;
console.log(greekLetters.test("α")); // true
Note ES2024. The v flag replaces the u flag with enhanced Unicode support and set operations (&&, --) inside character classes.
regex v flagunicode setsregexp unicodecharacter class operations