├── index.html ├── main.js └── readme.md /index.html: -------------------------------------------------------------------------------- 1 | 2 |
3 | 4 |6 | Lorem ipsum dolor sit amet consectetur adipisicing elit. Harum nisi 7 | cupiditate, saepe quidem corrupti voluptatibus veritatis rem molestiae 8 | nobis repellendus distinctio? Id doloribus laboriosam voluptatem dolores 9 | qui inventore mollitia voluptatum? 10 |
11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /main.js: -------------------------------------------------------------------------------- 1 | 2 | const Person = function (firstName, birthYear) { 3 | // console.log(this) // {} 4 | this.firstName = firstName 5 | this.birthYear = birthYear 6 | 7 | 8 | 9 | // Never use this 10 | // this.calcAge = function () { 11 | // console.log(2022 - birthYear) 12 | // } 13 | } 14 | 15 | 16 | 17 | Person.prototype.calcAge = function () { 18 | // console.log(2037 - this.birthYear); 19 | return 2037 - this.birthYear 20 | } 21 | 22 | 23 | 24 | 25 | const hamzah = new Person("Hamzah", 2000) 26 | const areeb = new Person("Areeb", 2000) 27 | const arham = new Person("Arham", 2000) 28 | 29 | // 1. New {} is created 30 | // 2. function is called, this = {} 31 | // 3. {} linked to prototype 32 | // 4. function automatically return object 33 | 34 | 35 | // console.log(hamzah) 36 | // console.log(hamzah.hasOwnProperty("calcAge")) 37 | 38 | 39 | 40 | 41 | // class expression 42 | // const PersonCl = class { 43 | // constructor(firstName, birthYear) { 44 | // this.firstName = firstName 45 | // this.birthYear = birthYear 46 | // } 47 | // } 48 | // class declaration 49 | class PersonCl { 50 | constructor(firstName, birthYear) { 51 | this.firstName = firstName 52 | this.birthYear = birthYear 53 | } 54 | 55 | clacAge() { 56 | console.log(2037 - this.birthYear); 57 | } 58 | } 59 | 60 | 61 | const ali = new PersonCl("Ali", 2000) 62 | const hamzah2 = new PersonCl("Hamzah", 2000) 63 | 64 | console.log(ali) 65 | 66 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | ## Commands 2 | - git init // initialize git (one time command) 3 | - git add . // add to staging area 4 | - git commit -m "updated index.html" // push to local repo with message 5 | - git remote add origin