Skip to content

Instantly share code, notes, and snippets.

@bartcis
Created June 3, 2019 14:31
Show Gist options
  • Select an option

  • Save bartcis/e935e57466aea9a010f7072e9c29d960 to your computer and use it in GitHub Desktop.

Select an option

Save bartcis/e935e57466aea9a010f7072e9c29d960 to your computer and use it in GitHub Desktop.
JS value as type simple example
// 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