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: Omar Qaqish, Nur Abunamus, Bedreddin Naser, Harith Riyadh
0. In array we are access the data through indexes, while in objects, we access the data through keys and properties.
Another example: let obj = {“foo.Bar”: 2}
obj[“foo.Bar”] // valid syntax
obj.foo.Bar //invalid syntax
let propertyname = 'c'; let obj ={ a : 11, b : 12, [propertyname] : 13 };
const teamNames {
name1 : “Nur”,
name2 : “Omar”,
name3 : “Bedreddin”,
name4 : “Harith”,
}
Object.keys will return an array that looks like [name1, name2, name 3, name4]
Object.entries will return an array with the keys and values.