Skip to content

Добавьте метод insertAt(index, element, array) для массива, пожалуйста #59

@blazkovicz

Description

@blazkovicz

Очень часто нужно добавить элемент в массив по индексу и вернуть новый массив.
Такое простое действие каждый раз порождает неприятные конструкции в коде:

 const newArray = [...array]

 newArray.splice(index, 0, newElement)

или

const newArray = array.slice(0, index).concat([newElement]).concat(array.slice(index))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions