Skip to content

Instantly share code, notes, and snippets.

@tech-chieftain
Forked from halitbatur/discussion.md
Created October 8, 2022 08:23
Show Gist options
  • Save tech-chieftain/f35b43e1adb094a262422c9c222811e1 to your computer and use it in GitHub Desktop.
Save tech-chieftain/f35b43e1adb094a262422c9c222811e1 to your computer and use it in GitHub Desktop.
Object discussion questions

Object Discussion Questions

There is some coding in this discussion. Feel free to write them in a REPL or in the comments below.

  1. How is an object different from an array?
  2. How does const work with objects?
  3. 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.
  4. What are computed properties? Write an example code.
  5. What is the difference between Object.keys and Object.entries? Write example code using both of them.
  6. How do we get only the values of an object?
@dilaracetinberk
Copy link

  1. Object is a data type, array is an object as well. Object has properties like boolean,strings etc.
  2. we use const with the object if we don't want to change the value which is certain.
  3. Sometimes it is impossible to access those properties with dot notation. wildKeys.'string' ;
    3

@caglabircan
Copy link

caglabircan commented Oct 8, 2022

  1. Objects can store pairs (keys and values). Arrays only store values.
  2. Const creates a binding so we can't use the same name with another object.
  3. Dot notation is easier to read and write. Cheat: Square bracket notation allows access to properties containing special characters and selection of properties using variables.

4.The Object.keys() function returns an array of the object's own properties. Object.entries() function returns an array of entries.
5.Object.values

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment