Skip to content

Instantly share code, notes, and snippets.

@camckin10
Created December 7, 2016 02:34
Show Gist options
  • Select an option

  • Save camckin10/874168ddc9821eb846070076d4c966eb to your computer and use it in GitHub Desktop.

Select an option

Save camckin10/874168ddc9821eb846070076d4c966eb to your computer and use it in GitHub Desktop.
Object basics drills
//object creator
function createMyObject () {
return {
foo: 'bar',
answerToUniverse:42,
'olly olly': 'oxen free',
sayHello: function () {
return ('hello');
}
}
}
//object updater
function updateObject(obj) {
obj.foo = 'foo',
obj.bar = 'bar',
obj.bizz = 'bizz',
obj.bang = 'bang',
return obj
}
//deleting keys
function keyDeleter(obj) {
delete obj.foo;
delete obj.bar;
return obj
}
var sampleObj = {
foo: 'foo',
bar: 'bar',
bizz: 'bizz'
bang: 'bang'
};
//self reference
function personMaker() {
var person = {
firstName = 'Chelsey',
lastName = 'McKinney',
fullName: function () {
return (this.firstName + " " + this.lastName);
}
return person;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment