B
B
Bur Ov2016-12-15 15:03:46
Arrays
Bur Ov, 2016-12-15 15:03:46

How to correctly compose a link from a js array?

Let's say we have an array:
var array = [1,2,3,4,5,6,...,999];
How to correctly compose such a link, from the first 500 array values:
https://test.ru?test=1 ,2,3,4,5,6,...500
Do not write https://test.ru?test =array[0] ,array[1]
I understand what is needed through the loop, but I don't understand how exactly.
Thank you for your attention.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
roswell, 2016-12-15
@burov0798

var arr = [ 1, 2, 5, 10, 20, /* ещё куча элементов */ 999 ];
var url = 'http://example.org/?test=' + arr.slice( 0, 500 ).join( ',' );

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question