JavaScript Lessons

How method toString works

In this lesson will see, how the method toString in JavaScript works and how we can modify this method. Each object in JavaScript contains a toString method, and this method returns a textual representation of the object. 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.

Read more

Callbacks in Javascript

In this lesson will be callback in Javascript described. A callback is a function passed as an argument to another function. This technique allows a function to call another function. 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.

Read more

How JSON in JavaScript works

This lesson will be about JSON. Shortcut JSON means JavaScript Object Notation, Is possible to say, that JSON is a JavaScript object written as text string. 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.

Read more

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.

Read more

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.

Read more

What is constructor in javascript class

Hello, today will see, how constructors in JavaScript classes works 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.

Read more