Created
July 19, 2020 01:09
-
-
Save moisescastillo/1f1c30a4755a99696f4dae81c56b69d9 to your computer and use it in GitHub Desktop.
JavaScript object basic
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
const person = { | |
name: {first:'Bob', last: 'Smith'}, | |
age: 32, | |
gender: 'male', | |
interests: ['Music', 'Boxing'], | |
greeting: function() { | |
console.log(`Hi, I\'m ${this.name.first}`); | |
}, | |
fullName: function() { | |
console.log(`${this.name.first} ${this.name.last}`); | |
} | |
} | |
person.greeting(); | |
// -> "Hi, I'm Bob" | |
person.fullName(); | |
// -> "Bob Smith" | |
console.log(person.age); | |
// -> 32 | |
console.log(person.interests[1]); | |
// -> "Boxing" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment