CxD Archive
Intro to Informatics and Web Development
Intro to Informatics and Web Development
  • Intro to Informatics and Web Development - Front Page
  • 1-1 Intro to Code References
  • 1-2 Basic HTML
  • 1-3 Basic CSS
  • 1-4 Classes and IDs
  • 1-5 Javascript
  • 1-6 Javascript Objects
  • 1-7 If...Else Statements
  • 1-8 For Loops
  • 2-1 Intro to User and Product Research
  • 2-2 Product Investigation
  • 2-3 Interviews
  • 2-4 Personas
  • 3-1 Intro to Interaction Design
  • 3-2 Sketching Interfaces
  • 3-3 Prototypes and Interaction Storyboards
  • 1-8 For Loops
Powered by GitBook
On this page
Export as PDF

1-6 Javascript Objects

Previous1-5 JavascriptNext1-7 If...Else Statements

Last updated 6 years ago

An object is a collection of related data and/or functionality. This usually consists of several variables and functions, called properties and methods when they are inside objects.

Properties are the values associated with an object. They can usually be modified, added, and deleted.

Methods are the actions that can be performed on objects. They are properties containing a function definition.

This would all work the same in a video game. In a video game, you might have a character object. You can create as many versions of that character object as you need.

Properties of the character object could be hair style, skin color, clothing, eye color, weapon, special move, etc. Each of those properties would have a value:

character1.clothing = "red_flame_dress"
character1.weapon = "fireball"
character1.eyeColor = "blue"

This could all be combined in code like this:

var character1 = {clothing:"red_flame_dress", weapon:"fireball", eyeColor:"blue"};

The character would also have methods associated with it. The character could do things like walk, run, use their weapon, etc. It would look like this:

character1.run();
character1.throwFire();
Car Object Example