Represents either a single item or an array of items.
Essential for flexible APIs that accept both individual items and collections, reducing the need for separate method overloads.
function addClass(elements: OneOrMany<Element>, className: string): voidaddClass(document.body, 'active'); // single elementaddClass([el1, el2], 'active'); // multiple elements Copy
function addClass(elements: OneOrMany<Element>, className: string): voidaddClass(document.body, 'active'); // single elementaddClass([el1, el2], 'active'); // multiple elements
Represents either a single item or an array of items.
Essential for flexible APIs that accept both individual items and collections, reducing the need for separate method overloads.