Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to swap two elements in an array js

// Since ES6
[a[0], a[1]] = [a[1], a[0]]
 
PREVIOUS NEXT
Tagged: #swap #elements #array #js
ADD COMMENT
Topic
Name
2+3 =