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: Mohammad Sheikh Ibrahim, Mustafa Arslan, Israa Qaba, and Kinan Hatahet.
0. Objects have keys and values unlike arrays. Objects keys are more descriptive index than number in the arrays.
e.g. ar.var_namr wouldn't work , but ar["var_name"] works
e.g. const person ={
name:"aname",
surname:"aasd"
}
const here="name"
console.log(person[here])
With Object.keys, we can return only the keys. However, object entries return a pair of the key and the value.
e.g.
const person ={
name:"aname",
surname:"aasd"
}
console.log(Object.keys(person)) >> ["name","surname"]
console.log(Object.entries(person)) >> [["name","Aname"],["surname","assd"]]
with Object.values.