Javascript Datatypes 2

Please Click on this link to access the resource folder for this lesson.

Data types (Boolean)

  • The boolean type has only two values: true and false.
  • This type is commonly used to store yes/no values: true means “yes, correct”, and false means “no, incorrect”.
  • Boolean values are mostly gotten from comparisons:

Data types (null)

  • The value null represents the intentional absence of a value
  • The null type is a special value which represents “nothing”, “empty” or “value unknown”.
  • Note that type of null is object for legacy reasons
  • An unassigned variable is automatically set to type null
  • Use null to assign an “empty” or “unknown” value to a variable

Data types (undefined)

  • The value undefined means a value is not assigned
  • A declared variable without assigned values becomes undefined by default
  • Show example of type of undefined

Data types (object)

  • Objects are one of the most important data type in JavaScript
  • Objects are used to store keyed collections of data and more complex entities.
  • All other types are called “primitive” because their values can contain only a single value
  • Objects are associative arrays with several special features. They store properties (key-value pairs), where:
  • You can retrieve values using dot notation or with square brackets
  • Objects are store any valid JavaScript type including objects themselves
  • delete a property: delete obj.prop.

Scroll to Top