Best Jquery ,javascript, HTML5 CSS3 tutorial with jquery examples, php script , demos for beginners, web designers and web developers.

Jquery

Jquery, javascript Training

Jquery training blog

Object-Oriented programming in javascript

Object-Oriented programming

Object-Oriented programming is a programming paradigm  based on concept of a objects, that uses abstraction to create model based on real world. It is a model organized around objects rather than “actions” and data rather than logic.

OOP provides a clear modular structure for programs.OOP makes it easy to maintain and modify existing code as new objects can be created with small differences to existing ones.

OOP is widely popular in large-scale software engineering. It is easy to model a real system as real objects are represented by programming objects in OOP.

In OOP, data can be made private to a class such that only member functions of the class can access the data. This principle of data hiding helps the programmer to build a secure program that can not be invaded by code in other part of the program.

Programming languages such as Java, JavaScript, C#, C++, Python, PHP etc support object-oriented programming (OOPs).

JavaScript supports Object Oriented Programming but not in the same way as other OOPs languages such as c++, Java, python, php etc.

JavaScript has strong object-oriented programming capabilities. But there is a difference in oop of  javascript compared to other programming languages .

Terminologies that we use in object-oriented programming.

Class: Defines the characteristics of the Object.

Object: An Instance of a Class. A class is a blueprint or prototype from which objects are created
Constructor: A method called at the moment of instantiation.
Method: An Object capability as walk.
Property: An Object characteristic, such as color.
Inheritance: A Class can inherit characteristics from another Class.
Encapsulation: A Class defines only the characteristics of the Object, a method defines only how the method executes.
Abstraction: Abstraction is the process of taking away or removing characteristics from something in order to reduce it to a set of essential characteristics.

The Class in JavaScript
JavaScript does not contains class statement like Java, C++ etc. JavaScript is a prototype-based language. JavaScript uses functions as classes. Defining a class is as easy as defining a function.

<!DOCTYPE html>

<html>
<body>

<p id="javascriptdemo"></p>

<script>
function jquerytraining(first, last, age) {
this.firstName = first;
this.lastName = last;
this.age = age;
}
jquerytraining.prototype.name = function() {
return this.firstName + " " + this.lastName
};

var jqueryobject= new jquerytraining("John", "Doe", 50);
document.getElementById("javascriptdemo").innerHTML =
"My father is " + myFather.name();
</script>

</body>
</html>

 

Please follow and like us:





Got Something To Say:

Your email address will not be published. Required fields are marked *

*


About the author

Joydeb Choudhury holds a Master's degree in Computer Application from I.G.N.O.U. After working as a web developer in various companies he has started bloging in 2016.

Recent Posts of blog

Downalod Free Php Scripts