Basic 3 Flashcards
1
Q
Formula to create an object
A
const person = { firstName: 'Steve', lastName: 'Nuts' age: 34 }
2
Q
how can you select values from objects? 2 methods and which one it’s the most common.
A
val = person. firstName; val = person ['lastName'];
3
Q
how can you do a function in an object?
A
getBirthYear: funcition() {
return 2021 - this.age;
}
4
Q
How can you get the state alone in a console?
const person = { firstName: 'Steve', lastName: 'Smith', age: 45, email: 'joh@dk.com', hobbies: ['music', 'sports'], address: { city: 'Miami', state: 'FL' },
A
val = person.address.state;
NOTE: REMEMBER TO ASIGN A VALUE ON A OBJECT YOU HAVE TO USE : INSTEAD OF =
5
Q
how can you call the result of the function?
A
val = person.getBirthYear();