nehaadmec

Best learning comes with passion and dedication.
 
Object Oriented JavaScript

JavaScript programming language is growing rapidly these days in the industry. Having good knowledge is required in every field such as front-end development, web designing, full-stack development, web development and many more.
It is true that for better career scope, you need to learn from scratch and for that you want to go for some professional web development courses in Delhi.

We all know JavaScript Is the most famous language among developers because it is open-source, dynamic, lightweight programming language.

JavaScript is mainly used to add interactivity to the web pages. After making a static website design we need something for making website dynamic in which user can also interact with it and by adding JavaScript we can solve this problem.

Try learning this language with JavaScript course in Delhi.

What is Object oriented JavaScript?
Like PHP, JavaScript is not a class bases object oriented programming language. But it has some properties with the help of we can use OOP (object oriented programming) in JavaScript.

According to the name Object oriented programming is directly related to the objects. Object refers to a collection of properties with pair of keys and values.

For example:
const fruit = {
name: "apple",
color: "red",
}

So, in simple words object oriented programing is a process of creating different object with a common object. There are some short topics you need to understand. Let’s see them one by one.

Class Implementation in JavaScript
class fruits{
constructor(name, color) {
this.name = name;
this.color = color;
}
getDetails(){
return (`The name of the fruit is ${this.name}.`)
}
}
let fruit1 = new fruits('Banana', Yellow');
let fruit2 = new fruits('Orange', 'orange');
console.log(fruit1.name);
console.log(fruit2.color);
console.log(fruit1.getDetails());

Output :
Banana
orange
The name of the fruit is Banana

Encapsulation in JavaScript
Encapsulation in JavaScript is the process of binding the data into a single unit to protect it from outer functions. In simple words, Private function is can be access only by their current function and not accessible to the global functions. For example:
const fruits = function(n, c) {
let name= n;
let color= c;
return {
summary : function() {
console.log(`The name of the fruits is ${name} and the color is${color}.`);
}
}
}
const fruits1 = new fruits('Banana', 'Yellow');
book1.summary();

Output :
The name of the fruits is Banana and the color is Yellow.

Abstraction in JavaScript :
Abstraction in JavaScript is a process of hiding implementation details and only showing the essential features. It is more advance then Encapsulation in JavaScript.

Let’s see and example:
const fruits = function(getName, getColor) {
// Private variables / properties
let name = getName;
let color = getColor;
// Public method
this.giveName = function() {
return name;
}

// Private method
const summary = function() {
return `The name of the fruits is ${name} and the color is${color}.`
}
// Public method that has access to private method.
this.giveSummary = function() {
return summary()
}
}
const fruits1 = new fruits('Apple', 'Red');
fruits1.giveTitle();

Output :
"Apple"
fruits1.summary();

Output :
Uncaught TypeError: fruits1.summary is not a function
fruits1.giveSummary();

Output :
"The name of the fruits is Apple and the color is Red."
There are many more concepts are present in Object oriented JavaScript such as:
• Reusability/inheritance
• Polymorphism
• Association
• Aggregation
• Composition

Go for proper level of training with web design courses in Delhi.

nehaadmec

nehaadmec
Datum rоđenja:  03.05.2000 Pol:  Ženski Član od:  03.02.2022 VIP izbora:  0 RSS RSS Feed