Use Of Javascript With OOP Concepts

Javascript With OOP Concepts

What is OOP?



Basically OOP is the abbreviation for object-oriented-programming. 

Object-oriented-programming is a programming language modal for software design revolves around objects or data instead of functions and logics.That means it is a modal which is wrapped around objects that uses in the computer programming.In the other word it focuses on what developers want to be manipulate rather than how they want to manipulate  them.
There are only 4 object-oriented concepts in computer programming.Those are,
  • Inheritance :  This is a special feature of OOP which helps to use the same type of behaviors of one class for another class.This feature holds a behavior like what the parent and child have.
EX: Assume that there are some classes called parrots,owls,and bats.All of them are having some same behaviors.So that all the similar functionalities can be included in one class called birds and then the other classes can use them when they need it.Anyways if they have their own habits they can include those things inside of their own class.
  • Abstraction : This concept has the same meaning of the word.Extract all the essential things and hide other things.
EX: Imagine your resume.In our resumes we only includes the things related to our best professional talents. Usually we don't include our extremely personal things.So that is what the abstraction means,Expose the essential details
  • Encapsulation : This concept has came up with the need of hiding the sensitive data such as passwords.This is basically like making a cover and put the extremely sensitive data inside of that cover.In another way this is what keeping classes as private and provide some public methods to access it.
EX: In the banks there are operators who has the authority to login to the bank systems. But the account holders don't have the direct access for those things.This is an example for real life encapsulation.
  • Polymorphism  : This concept has two parts.Method overriding and method overloading.Method overriding is basically  having the methods with the same name and the same parameters.Method overloading is  having the methods with the same name and but the different parameters.

What is Javascript?


Javascript (JS) is a programming language which uses for web development.Both HTML and CSS can be updated and changed using JS. And also JS have the ability of calculate ,Manipulate and validate data.
JS considers as a single threaded language even though there are ways to create new threads. Specialty in the JS it is not waiting until the I/O (input and output) operations to get complete.instead of that it continues the execution of the program. This is the non blocking I/O concept that JS has.
JS has the ability of multi-paradigm. That is the special concern of this post.That means JS has the ability to work with OOP concepts.

JS Class , Objects ,This Keyword , Prototypes ,Strict Notation And Closure

JS Class And Objects

To create the class use class keyword and keep remember to add the constructor() method.In every time the class object initialized the constructor method will called.

EX:

To create objects JS uses 'new' as a keyword.These objects are considered to be singleton.
EX:
According to this example "mycar" is a object reference to Car class.

This Keyword

Basically this keyword is uses as a reference, to the current object.
EX:
 Answer:


Prototype

This is very similar to to inheritance concept.All the objects inherit properties and methods from prototype.

EX:
Strict Notation
Strict notation is used to write the secure codes in JS. This helps the developer to use correct syntax when coding. 

Closure

This is the method of using a function which returns another function.In the real meaning this closure is used for the encapsulation purpose.This encapsulate the  variables into a function and restricts the access of the outsiders.

Comments

Popular posts from this blog

"status": 404, "error": "not found", "message": "no message available", "path": "/api/employee"

There was an unexpected error (type=Not Found, status=404). No message available in Springboot