UX Design and Development course

JavaScript Core Types

The JavaScript language has 6 core types that are used when creating functional applications.


  • Only one type is called a number
  • NaNis a number error
var foo = 12


  • 16 bit chars inside single or double quotes
  • Strings are immutable variables
var foo = "Seattle, it rains a lot, but it's pretty kick ass!"


  • Truthy
  • Falsy

Truthy and Falsy Values in JavaScript

When we say that a value is "truthy" in JavaScript, we don't just mean that the value is true. Rather, what we mean is that the value coerces to true when evaluated in a boolean context.

There are only six falsy values

  • false
  • null
  • undefined
  • NaN
  • 0
  • " "


Represents the 'nothing' of JavaScript


JavaScript puts "undefined" on anything that does not have a value or things that are falsy


  • Object is a collection of key:value pairs. In most languages this is called a "hash".
  • Objects are dynamic, means that new methods can be added at runtime
  • Each object has a prototype

An object literal is a comma-separated list of name-value pairs wrapped in curly braces. The following demonstrates an example object literal:

var myObject = {
    sProp: 'some string value',
    numProp: 2,
    bProp: false

Object literals are used as a means of encapsulating data, enclosing it in a tidy package to minimize the use of global variables which can cause problems when combining code.