Created
January 8, 2020 08:14
-
-
Save epranka/eb7e0d509e1bb8b7574109c6f6bf95c1 to your computer and use it in GitHub Desktop.
Fast way to change variable type between number and string.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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