{"ScriptPreparationCode":"var data = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99]\r\n\r\nfunction moveItemBySplice(from, to) {\r\n // remove \u0060from\u0060 item and store it\r\n var f = data.splice(from, 1)[0];\r\n // insert stored item into position \u0060to\u0060\r\n data.splice(to, 0, f);\r\n}\r\n\r\nfunction moveItemByCopyWithin(from, to) {\r\n const f = data[from];\r\n if (to \u003E from) {\r\n // copy items after \u0060from\u0060 until \u0060to\u0060 one index to the left\r\n data.copyWithin(from, from \u002B 1, to \u002B 1);\r\n } else {\r\n // copy items from \u0060to\u0060 until before \u0060from\u0060 one index to the right\r\n data.copyWithin(to \u002B 1, to, from);\r\n }\r\n // insert stored item into position \u0060to\u0060\r\n data[to] = f;\r\n}\r\n","TestCases":[{"Name":"Move element by Array.splice()","Code":" moveItemBySplice(3, 40);\r\n moveItemBySplice(50, 10);\r\n moveItemBySplice(45, 96);\r\n moveItemBySplice(7, 15);","IsDeferred":false},{"Name":"Move element by Array.copyWithin()","Code":" moveItemByCopyWithin(3, 40);\r\n moveItemByCopyWithin(50, 10);\r\n moveItemByCopyWithin(45, 96);\r\n moveItemByCopyWithin(7, 15);","IsDeferred":false}]}