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
constwork 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.keysandObject.entries? Write example code using both of them. - How do we get only the values of an object?
0- object represent real worlds entities and their properties like cars and their properties like color model and so on . Is collection of keys and values, On the other hand, an array is a collection of items that are ordered and indexed by their position and Each item in an array can be of any data type and is accessed by its index ,which is a number starting from 0 .
2- using const with objects will prevent you from reassigning the variable to a new object, but it will not prevent you from modifying the properties of the object.
3- const obj = {
firsname: "room 3 ",
'last-name': "wiinng",
}
console.log(obj["last-name"])
console.log(obj.last-name)
onst fruits = ['apple', 'banana', 'orange'];
const fruitObject = {
[fruits[0]]: "red",
[fruits[1]]: "yellow",
[fruits[2]]: "orange"
}
console.log(fruitObject);
4- Object.keys dynimic naming
Object.entries give the hole thing in an array
5-obj.values