简体   繁体   中英

Javascript - Change index of array element

I have an array with

[1,2,3,4,5]

I want to move "2" right (1 position at the time) or move "2" left

Can we do that with RxJS Operators?

you can do it with regular javascript

 Array.prototype.move = function(from, to) { this.splice(to, 0, this.splice(from, 1)[0]); }; 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM