-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Open
Description
3057 - Push
Push is beautifully simple. It works just like the array prototype method. Not only that, it has a very simple implementation as well.
🎥 Video Explanation
🔢 Code
import type { Equal, Expect } from './test-utils'
type A1 = Push<[], 1>;
type B1 = [1];
type C1 = Expect<Equal<A1, B1>>;
type A2 = Push<[1, 2], '3'>;
type B2 = [1, 2, '3'];
type C2 = Expect<Equal<A2, B2>>;
type A3 = Push<['1', 2, '3'], boolean>;
type B3 = ['1', 2, '3', boolean];
type C3 = Expect<Equal<A3, B3>>;
// ============= Your Code Here =============
type Push<T extends unknown[], U> = [...T, U];➕ More Solutions
For more video solutions to other challenges: see the umbrella list! #21338
Metadata
Metadata
Assignees
Labels
No labels