Seems like always going back to the basics is key to growing in your journey as a developer. I find that if I am not consistently doing projects using all the tools then I forget. In my current situation there is not many peers to jump ideas off ect, so sometimes going to a beginner course for Javascript as the one offered in FreeCodeCamp helps tremendously. My “ah ha” moment came when I was almost done with basics of JS section and started with objects and how to access them. Writing code is great but it really comes down to (write code, compute, access values, and display).


Creating the Object in Javascript

There was a magical thing that happened with OOP was thought of and till this day I think it is a powerful concept. Create objects let them have duties, hold data ect, and then pull from them for your desired outcome.

An object could look like this:


How to access the object

You have a couple choices in this case I am going to go with dot notation “.” and also bracket []. I personally have no preference but the neat part is some of the differences.

Dot

  1. Property identifies can only be alphanumeric (and _ and $)
  2. Identifier cannot start with a number
  3. Identifier cannot be a variable

Bracket

  1. Identifier has to be a string or variable representing a string
  2. You can use variables, strings, spaces, and numbers for your identifier

Fun fact with both of these if you flatten your object and it is returned in dot notation you can then call on multiple objects using the bracket notation.


Conclusion

I literally wanted to jot this down as when you are making amazing code which is great the bigger it grows naturally you have to place objects together that hold data and so much more, so knowing some options from a beginner level on how to access them is key. As always I write this for myself but if anyone ever gets a little help from it then that is even better.

%d bloggers like this: