UX Design and Development course

Let's talk about objects - turn this up to 11

An object is any piece of data that has it's own properties and methods

Properties are key/value pairs

If I am an object "Dale", I would have the following properties (or variables)

  • hair: brown;
  • height: 69";
  • age: old;
  • music: metal;

I could also have the following methods (or the thing that the object does)

  • 'drive a car';
  • 'take a bus';
  • 'teach a class';
var person = {
  name: 'Dale',
  hair: 'brown',
  height: 69,
  age: 'old',
  music: 'metal'
};

Use the [dot] separator to get the value of an object's property.

console.log('This is ' + person.name + '. ' + 'His hair is ' + person.hair + ' and is ' + person.height + ' inches tall. He is ' + person.age + ' and listens to ' + person.music);

Play with code

JS Bin