K
K
Kooper_pro2018-03-26 21:27:13
JavaScript
Kooper_pro, 2018-03-26 21:27:13

How to append to an associative array between elements?

There is an array
img_array=[];
data is written as follows
img_array[id]=[urls];
Data looks like this:
green:["img/img1.jpg"]
white:["img/img2.jpg"] balck
:["img/img4.jpg"]
blue:["img /img3.jpg"]
So here's how to add data between the white key and balck while keeping the order?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Ruslan., 2018-03-26
@LaRN

Judging by the description, you have a regular index array. And if so, then you need to search by index to find the element with the black key, and then use the splice method to add a new element to the array at the found position.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question