Javascript examples for Array Operation:Array Element
Move or swap element inside an object
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=( function() {//w w w . j av a 2 s. co m var arr = [0,1,2]; function swapElements(a, x, y){ var temp = a[x]; a[x] = a[y]; a[y] = temp; } console.log(arr); swapElements(arr,0,1); console.log(arr); }); </script> </head> <body> </body> </html>