Created
June 3, 2019 14:31
-
-
Save bartcis/e935e57466aea9a010f7072e9c29d960 to your computer and use it in GitHub Desktop.
JS value as type simple example
This file contains hidden or 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
| // declare your variable - default type - number | |
| // Type is assigned to a value eg. 10 is a number (not variable level) | |
| let level = 10; | |
| // I change numeric value of level's value | |
| level = 15; | |
| // I change value type to string - explicit coercion | |
| level = String(level); | |
| // I check type of variable (it's value's type acctually) | |
| // I get string | |
| console.log(typeof (level)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment