From 2f9c15b6eff4cf39bf6965f98e47ed060c99aea0 Mon Sep 17 00:00:00 2001 From: DrMadWill <87474631+DrMadWill@users.noreply.github.com> Date: Tue, 7 Dec 2021 13:40:59 +0400 Subject: [PATCH] 13 OOP > Object > Inheritance > add --- .../Js/43_13_1_Object.js | 36 +++++++++++++++++-- .../JavaScripts/5_3_1_DateTimeMethods.js | 1 + .../13_Object_Oriented/documentation.md | 8 +++++ README.md | 4 ++- 4 files changed, 46 insertions(+), 3 deletions(-) diff --git a/13_Object_Oriented_Programming/Js/43_13_1_Object.js b/13_Object_Oriented_Programming/Js/43_13_1_Object.js index 21ddc2d..042cc60 100644 --- a/13_Object_Oriented_Programming/Js/43_13_1_Object.js +++ b/13_Object_Oriented_Programming/Js/43_13_1_Object.js @@ -58,12 +58,44 @@ class Student{ } let student2=new Student("15b","Sakura",15); // instance -console.log(student2) -console.log(student2.BirthYear()) +// console.log(student2) +// console.log(student2.BirthYear()) +//** Inheritance +class Person { + constructor(name,yearOfBirth,job){ + this.name=name + this.yearOfBirth=yearOfBirth + this.job=job + + this.CaculateAge=function(){ + let date =new Date + return date.getFullYear() - this.yearOfBirth + } + } +} + + +Person.prototype.GetName=function(){ + return this.name +} + +Person.prototype.lastName="Domation of Road" + + + +let mad = new Person("Mad",15,"Developer") +let will = new Person("Will",21,"Wayer") +console.log(mad) +console.log(mad.lastName) +console.log(mad.CaculateAge()) +console.log("*********************") +console.log(will) +console.log(will.lastName) +console.log(will.GetName()) diff --git a/3_Methods/JavaScripts/5_3_1_DateTimeMethods.js b/3_Methods/JavaScripts/5_3_1_DateTimeMethods.js index ee96542..b04c49b 100644 --- a/3_Methods/JavaScripts/5_3_1_DateTimeMethods.js +++ b/3_Methods/JavaScripts/5_3_1_DateTimeMethods.js @@ -34,6 +34,7 @@ let dtA=new Date('1/1/1990'); + let getOfDate=dtA.getDate(); dtA.setDate(getOfDate-1) diff --git a/Documantation/13_Object_Oriented/documentation.md b/Documantation/13_Object_Oriented/documentation.md index f85c8ae..9fd47da 100644 --- a/Documantation/13_Object_Oriented/documentation.md +++ b/Documantation/13_Object_Oriented/documentation.md @@ -15,3 +15,11 @@ ## (Funcition)Constractor C# daki classlarla eyni anlayşdır. > Yaradcağımız obeyktlərin qəlibidir. + +## Inheritance +> Bir Parent obyektində yaradılacaq obyektlərin əsas xususiyyətlərini yığaraq Child obyektləri ondan törədirik. + +### Prototype +> Hər bir obyektin `prototype`ı olur və əgər biz hər hası bir obyektin yardılmasında `class`dan istifadə edəriksə bu zaman həmin obyektin xususiyyətlərni kopyalayır ancaq `prototype`dan istfadə edəriksə onda parent obyektin xususiyyətlərindən istfadə edir ancaq özünə kopyalamır bu yaddaşda az yer tutur. +- `prototype` yazılan dəyərlər sabitdir +- Əsasən hər obyektə aid ümümi xususiyyətləri `prototype` da tutulur. \ No newline at end of file diff --git a/README.md b/README.md index ecda070..2668168 100644 --- a/README.md +++ b/README.md @@ -108,4 +108,6 @@ - [Form Validation](https://github.com/DrMadWill/JavaScript/blob/main/12_JQery/42_12_11_Form_Validation.html) ### Object Oriented Programming -- Object and Constroctor +- [Object and Constroctor](https://github.com/DrMadWill/JavaScript/blob/main/13_Object_Oriented_Programming/Js/43_13_1_Object.js) + - [My Documantation](https://github.com/DrMadWill/JavaScript/blob/main/Documantation/13_Object_Oriented/documentation.md#object-oriented-programming) +- Inheritance \ No newline at end of file