Javascript Learn Object Oriented


Howdy folks,

JavaScript, launched in 1995, aimed at animating static sites with only HTML content. For many years it has been seen as a simple script language, unfortunately it has not seen enough value and reputation.

Over the past few years, with the emergence of web applications, it has gained significant value and has dramatically increased its popularity. However, there is a serious problem with the correct writing of JavaScript on the market. It is not a more serious programming language, but rather a simple scripting language. So C#, Java, C++, php, etc. object oriented, inheriting, etc., which developers are familiar with, unfortunately not in the interest of most JavaScript developers. Standard Procedurel programming continues.

However,serious applications are now emerging (Outlook, Gmail, etc.).) and serious modularity is needed for their writing and management. Here, in fact, the concept of OOP comes into play. So what is OOP?

Object Oriented Programming

It is a code management form where everything to be used in the programming flow is used as an object, divided into small modules. The biggest advantage is that it eliminates the code duplication.

Let’s say we’re modeling a cat. The cat is an animal. Animals have common characteristics. Instead of defining the common traits of each animal species separately, we define the common traits of the animal at a time. Then cat, Dog, etc. we also derive animal species from animal objects.

OOP is a detailed issue. I’m not going to go down in detail in this article. If you do not know, please do research on the internet.

JavaScript is an OOP language, but it is simply an inheritance, etc. he doesn’t allow the use of concepts. It is necessary to spend some effort for such a structure.

In JavaScript, we define our methods with function.

we see an example function. We call this function as follows.

This will open the alert window on the browser screen.

JavaScript Class

So how do we use our classes that are used to server side languages?

As follows:,

We defined a class named person and provided the first variables, name, surname, with the parameters.


we create a new object from our class. Then we show the name of the person object in the alert window.

It is a very familiar structure, but the interesting part is that we defined the method and class in the same way.

This is actually the part where things get complicated. Unfortunately, server side languages after a very nice structure does not seem to be.

So how do we add a method to our person class?

Here, we add a method called showVariable to the person class.

Then we call this method through the person object. So we actually got a whole class.

We have a problem. Let’s examine the following code,

Everything seems normal. Here, however, for each object we create with new person (), all methods in it are also created to occupy space in RAM (here the showVariable method).

Although this is a neglected problem, it would be best if a good JavaScript programmer did not ignore it.


  • Design

Leave A Reply

Your email address will not be published.