M
M
mamaanarhiya2018-03-15 11:06:34
JavaScript
mamaanarhiya, 2018-03-15 11:06:34

How to trim an array to a specific number of elements?

I have an array with an unknown number of elements. I need to have up to 5 elements in the array, how to do it? Only through for?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Perov, 2018-03-15
@mamaanarhiya

https://developer.mozilla.org/en/docs/Web/JavaScript...
arr.slice([begin[, end]]) // вернет новый массив

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question