There is some coding in this discussion. Feel free to write them in a REPL or in the comments below.
- How is an object different from an array?
- How does
const
work with objects? - Explain the difference between bracket syntax and dot syntax. Give an example of something that works with bracket syntax but not dot syntax. Give an example of something that works with dot syntax but not bracket syntax.
- What are computed properties? Write an example code.
- What is the difference between
Object.keys
andObject.entries
? Write example code using both of them. - How do we get only the values of an object?
Team members :Hisham Al Wattar , Sara Nafisa , Talal Bakkour
Dot syntax ex :
const student= { name: 'John', age: 20}; console.log(student['name']);
Bracket syntax ex :
const student= { 'first name': 'John', age: 20}; console.log(student['first name']);
ex :
const student= {name: 'John',age: 30,['country' + '_code']: 'us'}; console.log(person['country_code']);
Object.keys() ex :
const student= { name: 'John', age:18, city: 'Istanbul' }; const keys = Object.keys(student); console.log(keys); // output: ['name', 'age', 'city']
Object.entries() ex :
const student= { name: 'John', age: 18, city: 'Istanbul' }; const entries = Object.entries(student); console.log(entries); // output: [['name', 'John'], ['age', 18], ['city', 'Istanbul']]