Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

swap first and last element in array javascript

const array = [1, 2, 3, 4, 5];

const tmp = array.pop(); //[1, 2, 3, 4]
array.push(array[0]); //[1, 2, 3, 4, 1]
array[0] = tmp; //[5, 2, 3, 4, 1]
Comment

PREVIOUS NEXT
Code Example
Javascript :: js number format space 
Javascript :: form action using react 
Javascript :: function syntax js 
Javascript :: Supported by YAML but not supported by JSON: 
Javascript :: axios download file from url 
Javascript :: phoenix routes 
Javascript :: sum all odd in binary search tree recursion javascript 
Javascript :: range between two numbers 
Javascript :: arange 
Javascript :: javascript round big numbers 
Javascript :: declaring variable react hooks 
Javascript :: mock anonymous function jest 
Javascript :: Moto Racer game 
Javascript :: bigint type js 
Python :: python check if path does not exist 
Python :: python suppress warning 
Python :: pandas save file to pickle 
Python :: python get current file location 
Python :: check python 32 or 64 
Python :: django admin no such table user 
Python :: python delete file 
Python :: create python alias for python3 
Python :: sudo python3 -m pip install pyautogui 
Python :: copy text to clipboard python 
Python :: pandas find na 
Python :: invert y axis python 
Python :: get screen size python 
Python :: start a simple http server python3 
Python :: python delete saved image 
Python :: matplotlib text too small 
ADD CONTENT
Topic
Content
Source link
Name
5+3 =