Skip to content

Instantly share code, notes, and snippets.

@mimnets
Last active July 16, 2020 03:39
Show Gist options
  • Save mimnets/0a2aedc9fcc45bff380cfe848c718893 to your computer and use it in GitHub Desktop.
Save mimnets/0a2aedc9fcc45bff380cfe848c718893 to your computer and use it in GitHub Desktop.
Do you know how to swap two variable data? I know you did try it many times! Wait how I know? Because you are I, and I am you!!!
var abul = 100;
var babul = 99;
console.log("Before swap abul = ", abul, "babul = ", babul);
var temp = abul; //The temp value is now abul's value 100.
abul = babul // now abul has babul's value 99.
babul = temp //because temp has babul's value 100.
console.log("After swap abul = ", abul, "babul = ",babul);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment