Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript Swapping Variables

// program to swap variables

let x = 4;
let y = 7;

// swapping variables
[x, y] = [y, x];

console.log(x); // 7
console.log(y); // 4
 
PREVIOUS NEXT
Tagged: #javascript #Swapping #Variables
ADD COMMENT
Topic
Name
1+2 =