Skip to content

Instantly share code, notes, and snippets.

@epranka
Created January 8, 2020 08:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save epranka/eb7e0d509e1bb8b7574109c6f6bf95c1 to your computer and use it in GitHub Desktop.
Save epranka/eb7e0d509e1bb8b7574109c6f6bf95c1 to your computer and use it in GitHub Desktop.
Fast way to change variable type between number and string.
let a = '5';
a = +a; // convert it to a number
console.log(a, typeof a); // 5 number
a = ''+a; // convert it back to a string
console.log(a, typeof a); // '5' string
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment