We have a class called Car, which contains brand, color and maximum speed. We create an instance of the Car class named anyCar and add arguments to the constructor.
We see that in the sayHello function we pass the name as a parameter and in the body of the sayHello function we write the text Hello and the variable name in the document.
Here is simple sample od JSON, we see that the object is written in curly braces, and the properties are always written in quotation marks.
We can easily access the properties of this object.
How exactly Functions with return and global Variables works
Hello, today we will see, how functions work, in which command return is. We have defined the function increaseValue, which increases the variable A by the value 2 and at the same time returns the variable A with the command return. In the next step, we define that the value of the variable B should be equal to the value that the function increaseValue returns.
Write a variable in a text string using a dollar sign
Hello, today we're going to show how to write variables in text strings with using a dollar sign.
We see, that we have two variables declared and initialized, thus variable firstName with the value John and variable lastName with the value Cage. First we write the variable firstName into the text string by joining strings, where we must always add a plus sign between the variable and the text. The text must be placed in apostrophes.
A constructor is a method that starts automatically when you create a new instance of a any class. Constructor is used for initialization instance of class and is used too for creating properties of this instance.
If you dont write constructor into class, such class has defualt constructor, which is empty.