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.
- Property identifies can only be alphanumeric (and _ and $)
- Identifier cannot start with a number
- Identifier cannot be a variable
- Identifier has to be a string or variable representing a string
- 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.
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.