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?
Members: Cansu Aydagdic, Mohamad Aid, Mustapha Nori, İsmail Dincer
0- In arrays data are indexed and in order. In arrays an element can be accesed with its index. We should use arrays for numbers. In objects there are keys and values for those keys. In objects the values can be accesed by their keys. We should use objects to store strings.
1- We can change the const object's values and keys. However, you cannot assign it to be a different object.
2- Dot notation is faster to write and easier to read than bracket notation.
However, you can use variables with bracket notation, but not with dot notation. This is especially useful for situations when you want to access a property but don’t know the name of the property ahead of time. For example, if we wanted to iterate over all the keys in an object, and access their values, we could use bracket notation.
3-
4- Object.keys returns an array of keys of an object. Object.entries returns an array of keys and values of an object.
5- We use Object.values.