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?
0.How is an object different from an array?
Object is a data type
array is also an object.
Object has properties, each keys can store boolean, strings or numbers, anything we want.
main differences are;
=> Object has key value pairs features that allows us to define specific values for each keys.
=>Objects represent “things” with characteristics (aka properties), while arrays create and store lists of data in a single variable.
1.How does const work with objects?
we use const with the object if we do not want to change the value once that variable has been initialized.
const person={
age:30,
name:"Halil",
}
//Dot notation
person.name="Halil",
//Bracket notation
person["name"]="Halil",
key differences
Bracket notation allows you to access properties with special characters in their names, while you can not do this with dot notation.
3.What are computed properties ?
Computed properties allow you to use the values of expressions as property names of an object.