When objects are called, they are usually followed by a . that tells us a property or a method is about to be called. Let’s hope this analogy works. Think of yourself as an object called you.
Now, you have properties about yourself. So, if I typed you.hairColor , I would expect the results to be whatever hair color you had. That is an object property in a nutshell.
The variable example is a string and one of its main properties is length. We get 7 because “Welcome” has 7 characters.
Methods are actions of or on the object. Again using you as an object, you.standUp() would make you stand up.
While the strike() method seems vicious, it simply just puts a line through the object string. Notice how the methods have () after them. Sometimes, they require arguments very much similar to functions. Our last example didn’t require one, but now I’ll show you what it looks like if they do.
The method charAt has an argument of 3, which is why it is shown above as charAt(3). The charAt goes through a string and finds which character is at a position in the string. Since, we used 3 as the argument, it returns “c” because c is the 4th character from the left. Remember that most methods start from 0. So, charAt(0) would return “W”.
As you can see reference an object’s id is very common, but sometimes it is better to reference an object’s name.