Created
October 2, 2019 18:31
-
-
Save gusmcnair/420b2dc436d2ac0c7900888b7a321c5c to your computer and use it in GitHub Desktop.
Object basics assignment
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Object creator: | |
function createMyObject() { | |
return myObject = { | |
foo: "bar", | |
answerToUniverse: 42, | |
"olly olly": "oxen free", | |
sayHello: function() { | |
return "hello" | |
} | |
}}; | |
Update object: | |
function updateObject(obj) { | |
obj.foo = "foo"; | |
obj.bar = "bar"; | |
obj.bizz = "bizz"; | |
obj.bang = "bang"; | |
return obj; | |
} | |
Self-reference: | |
function personMaker() { | |
var person = { | |
firstName: 'Paul', | |
lastName: 'Jones', | |
fullName: function() { | |
return `${this.firstName} ${this.lastName}` | |
}, | |
}; | |
return person; | |
} | |
Key Deleter: | |
function keyDeleter(obj) { | |
delete obj.bar; | |
delete obj.foo; | |
return obj; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment