How to add item into spesific index of array?


I have an array and I want to add spesific value to a spesific index of the array.

It basically will work like .splice() method and will do something like this;


The array index count will be 32 at the end and the new item will be placed into 22. index for example. And the rest of the items’ indexes will increase.

There might be better way to do this, but something like this should work,

{{flatten(add(slice(1.arrays; 0; 3.newIndex); 3.newValue; slice(1.arrays; 3.newIndex; length(1.arrays))))}}

The first slice function will get an array up to the desired index, and the second slice will get the other half, and the add is used to insert a new value in the desired index.

1 Like

What does flatten do?

Thank you!

As we are using add function in conjunction with slice, the result will look like,

[[1,2],3, [4,5]]

after the transformation, so flatten will convert the generated sub-array to a single tree,



Hi @onurbolaca :wave:

I was wondering if you had a minute to check out @Runcorn’s great suggestion and if it worked for you.
If yeah, could you mark it as a solution in order to keep our community neat and clean? :white_check_mark:
Thanks a lot