RUVIDEO
Поделитесь видео 🙏

JavaScript Tutorial - 11 - Classes смотреть онлайн

||-- Introduction to Classes --||
JavaScript is an object-oriented programming (OOP) language we can use to model real-world items.
class Data {
constructor(name){
this._name = name;
this._designation = 'SE';
this._level = 3;
}

get name() {
return this._name;
}

get Designation(){
return this._designation;
}

get Level(){
return this._level;
}

incrementCodinglevel(){
this._level++;
}
}
const hari = new Data('Hari');
console.log(hari.name);
console.log(hari.Designation);
console.log(hari.Level);
hari.incrementCodinglevel();//Calling increment
console.log(hari.Level);

||-- Constructor --||
Although you may see similarities between class and object syntax, there is one important method that sets them apart.
It’s called the constructor method. JavaScript calls the constructor() method every time it creates a new instance of a class.

class data {
constructor(name ,department){
this.name = name;
this.department = department;
}
}


||-- Instance --||
An instance is an object that contains the property names and methods of a class, but with unique property values. Let’s look at our Data class example.
class data {
constructor(name ,department){
this.name = name;
this.department = department;
}
}
const Hari = new data('Hari','Developer');
const Aman = new data('Aman','Tester');

||-- Methods --||
Class method and getter syntax is the same as it is for objects except you can not include commas between methods.
class Data {
constructor(name, department) {
this._name = name;
this._department = department;
this._remainingVacationDays = 20;
}
get name(){
return this._name;
}
get department(){
return this._department;
}
get remainingVacationDays(){
return this._remainingVacationDays;
}
takeVacationDays(daysOff){
this._remainingVacationDays = this._remainingVacationDays - daysOff;
}
}

||-- Method Calls --||
Finally, let’s use our new methods to access and manipulate data from Data instances.
const Hari = new data('Hari','Developer');
console.log(Hari.name);
Hari.takeVacationDays(3);
console.log(Hari.remainingVacationDays)

||-- Inheritance --||
When multiple classes share properties or methods, they become candidates for inheritance — a tool developers use to decrease the amount of code they need to write.
With inheritance, you can create a parent class (also known as a superclass) with properties and methods that multiple child classes (also known as subclasses) share.
The child classes inherit the properties and methods from their parent class.
class Data {
constructor(name) {
this._name = name;
this._remainingVacationDays = 20;
}
get name() {
return this._name;
}
get remainingVacationDays() {
return this._remainingVacationDays;
}
takeVacationDays(daysOff) {
this._remainingVacationDays -= daysOff;
}
}
class Employee extends Data{
constructor(name,certifications){
super(name);
this._certifications = certifications;
}
}
const Hari = new Employee('Hari','JavaScript');

We can also call methods which is described in Parent class.
Hari.takeVacationDays(5);
console.log(Hari.remainingVacationDays);

In addition to the inherited features, child classes can contain their own properties, getters, setters, and methods.
class Employee extends Data {
constructor(name, certifications) {
super(name);
this._certifications = certifications;
}
get certifications(){
return this._certifications;
}
addCertification(newCertification){
this._certifications.push(newCertification);
}
}
Hari.addCertification('Genetics');
console.log(Hari.certifications);

Sometimes you will want a class to have methods that aren’t available in individual instances, but that you can call directly from the class.
static generatePassword(){
return Math.floor(Math.random() * 10000);
}

console.log(Data.generatePassword);
You cannot access the .generateName() method from instances of the Animal class or instances of its subclasses

console.log(newHari.generatePassword);//Undefined

static generateName() {
const names = ['Angel', 'Spike', 'Buffy', 'Willow', 'Tara'];
const randomNumber = Math.floor(Math.random()*5);
return names[randomNumber];
}

The example above will result in an error, because you cannot call static methods (.generateName()) on an instance (newHari)



No doubt, giving food to a hungry person is indeed a great donation, but the greatest donation of all is to give education. Food gives a momentary satisfaction where as education empowers the person for the rest of his life and enables him to earn his own food.


Let's gift education together
https://www.youtube.com/channel/UC5yQtrJotD8_a0VgYSQqYjg/featured

Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «JavaScript Tutorial - 11 - Classes» бесплатно и без регистрации, вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.

Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.

Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!

Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.