Objects
One thing we learned about in our Web Programming course this semester is Javascript objects. Objects are nice because it allows you to take in and store data in order to create something such as a profile or character. Objects are made up of key value pairs which look like this.
Name: Jake,
When you put many of these key value pairs you get an object
var dog = {
name: 'Fido',
breed: 'Yorkie',
sound: 'bark',
weight: '15 lb'
};
There a couple different ways to make objects you can do like the example did above or you can make and empty object and add values to it after using bracket notation.
var dog = {}
dog['name'] = 'Fido';
dog['breed'] = 'Yorkie';
dog['sound'] = 'bark';
dog['weight'] = '15 lb';
You can also put an object inside of another object.
var pc = {
brand: 'Dell',
hardDrive: {
size: '2TB',
type: 'sata'
}
};
You can also take user input and put them into your object as well. Objects are very versitile and useful when creating code.