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?
@omikay | @radmanlo | @muhammedhasann
aaccessing an object's property with a name that is not a valid identifier (like a string as a key) works with bracket syntax but doesn't work with dot syntax.
adding a new property to an object works with dot syntax but not bracket.
const car = 'bmw';
const myObj = {
[car]: 5
};
console.log(myObj.bmw);