Results for “Slices & collections”
Small, practical examples. Search by task or narrow things down below.
Find shared members of two sets
TypeScript: Filter one set through the other set’s membership test.
TypeScript✓ Tested
Find values missing from another collection
C#: Except removes duplicates as it calculates the set difference.
C#✓ Tested
Group records into map entries
JavaScript: Initialize an array for a missing Map key before appending its values.
JavaScript✓ Tested
Group records into map entries
TypeScript: Initialize an array for a missing Map key before appending its values.
TypeScript✓ Tested
Inspect overlapping windows
Inspect overlapping windows in a complete Rust program using the standard library.
Rust✓ Tested
Keep only values satisfying a condition
Keep only values satisfying a condition in a complete Rust program using the standard library.
Rust✓ Tested
List an object’s own enumerable keys
JavaScript: Object.keys omits inherited and non-enumerable properties.
JavaScript✓ Tested
List an object’s own enumerable keys
TypeScript: Object.keys omits inherited and non-enumerable properties.
TypeScript✓ Tested
Measure content, padding, and borders separately
jQuery: width, innerWidth, and outerWidth measure different parts of the box.
jQuery✓ Tested
Prevent runtime changes to top-level properties
JavaScript: Object.freeze prevents ordinary top-level mutations; Reflect.set reports the rejected update without throwing.
JavaScript✓ Tested
Prevent runtime changes to top-level properties
TypeScript: Object.freeze prevents ordinary top-level mutations; Reflect.set reports the rejected update without throwing.
TypeScript✓ Tested
Process a FIFO queue
C#: Queue removes elements in the order they were enqueued.
C#✓ Tested