这是indexloc提供的服务,不要输入任何密码
Skip to content

3057 - Push (🎥 Video Explanation and Solution) #21540

@dimitropoulos

Description

@dimitropoulos

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

Release Date: 2023-01-12 19:00 UTC

Push

🔢 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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions