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 member: Younes nourzehi, Tesnim nakiilci, Ahmad alashtar, Nezir aydin
arryas have index but in objects you need the key to access them. also objects are key and values but arryas have values only.
we can modify objects properties but we cant reassign them, but The const keyword makes a variable itself immutable, not its assigned content
Dot Notation only allows static keys while Bracket Notation accepts dynamic keys
for example:
const student = {name: 'ahmet', age: 24}
student.name static key
student['name'] bracket notation (dynamic)
the keys are dynamic in computed property
for example:
const property = 'age';
const student = {name: 'nezir',[property]: 20}
object keys it shows the keys of the object, but when using entries we get both the key and value
for example:
const student = {name: 'nezir, age: 23}
student.keys returns only [name,age]
but when we use student.entries it will return [[name,'nezir'],[age, 23]]
object.values
for example:
const student = {name: 'nezir, age: 23}
object.values(student)