I understand this diagram:
But now my question is... How can I add an element just in the second position of the Array?
If I have this array: (A, C, G, T) and I want to add B...
The result that I want should be: (A, B, C, G, T)
Any suggestions?
Thank you!
What you want is the splice function:
arr.splice(index, 0, item);
will insert item
into arr
at the specified index
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With