JavsScript Data Types - tdkehoe/blog GitHub Wiki

JavaScript has five primitive data types:

  • number: JavaScript has only one number type, for integers, floating point numbers, etc.
  • string: for text, or numbers interpreted as text.
  • boolean: true or false.
  • null: no value.
  • undefined: unspecified data type.
  • symbol: a new data type whose instances are unique and immutable.

#Converting Values Between Data Types

JavaScript is a dynamically typed language. This means that JavaScript will usually convert a value from one data type to another without the programmer having to specify anything. To explicitly convert between data types:

  • parseInt('380px') returns the number 380.
  • parseFloat('pi is 3.141592653589793') returns 3.141592653589793.

You can specify the number system with a radix parameter.

toString() converts a value into a string.