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?
group (mohamad aghi, aya mydani, sara hamoud, irem kurt)
0- Arrays store the data in an ordered collection in which the data can be accessed using a numerical index while objects store in a pair form. We must put [] to arrays and {} to objects. We access values through the index in the array while we access values through key.(object.key())
when we declare an object using const we cant redeclare it again and we cant reassign it also .
but we can make some changes to it means we can add, remove or edit keys and values.
the bracket notation allows us to access object properties using different values rather than the dot that just allows us to access the specified keys also we can't use variables with dot notation.
a property name that returns a value not just store it
Object.keys(obj) – returns an array of keys.
Object.values(obj) - returns an array of [key, value] pairs.
let user = {
name: "John",
age: 30
};
Object.keys(user) = ["name", "age"]
Object.entries(user) = [ ["name","John"], ["age",30] ]
object.values(obj)