• Saturday , 24 August 2019

Object Oriented JavaScript Tutorial #8 – Class Inheritance

Code Canyon



Hey gang, in this object oriented JavaScript tutorial I’ll teach you about Class Inheritance.

🐱‍💻 Course Links:

– VS Code editor – https://code.visualstudio.com/
– GitHub repository (course files) – https://github.com/iamshaunjp/object-oriented-js
– JavaScript for Beginners – https://www.youtube.com/watch?v=qoSksQ4s_hg&list=PL4cUxeGkcC9i9Ae2D9Ee1RvylH38dKuET

🤑 Donate @ https://www.paypal.me/thenetninja

🎓Find me on Udemy @ https://www.udemy.com/user/47fd83f6-5e4a-4e87-a0f0-519ac51f91b6/

👾 Video thumbnail artwork by PixelSwish @ https://www.youtube.com/channel/UCGKSD3mitWl5UpMxZzaIrRA

Original source

3d Ocean

Related Posts

23 Comments

  1. Hannah Herbst
    January 17, 2019 at 01:48

    Inheritance does seem useful, but I have worries. What if, later on, you need to add properties to the user class that admin does not require?

  2. lam pham
    January 17, 2019 at 01:48

    I try:
    admin.deleteUser(admin)
    but it's not work. Can you explain why?

  3. lam pham
    January 17, 2019 at 01:48

    Your tutorial is really amazing. keep up the good work

  4. john mcdonald
    January 17, 2019 at 01:48

    I wasn't able to chain the delete admin method with a console log. anyone any
    idea why?

  5. Dodo
    January 17, 2019 at 01:48

    you should have explained super()

  6. Ayush Jain
    January 17, 2019 at 01:48

    Easy and simple explanation of js
    keep up the good work

  7. VITO MOTORSPORT
    January 17, 2019 at 01:48

    Can you please describe why did you use array.filter() instead of array.find()?

  8. Android Games
    January 17, 2019 at 01:48

    King Of Ninjas, Thanks For These Tuts They're Very Helpful, But I Hope You Make A Small Project Using Javascript ES6 OOP, Like OOP Shapes, Wisky Machine, etc … 🙂

  9. Mohamed Hamidi
    January 17, 2019 at 01:48

    Hello , i was practicing after the video , i wanna know can i put the filter() function in separate function for example deletion() then call it in the deleteUser() function like that : users = users.filter(deletion);

  10. HAMRO GARAGE
    January 17, 2019 at 01:48

    After that deleteuser method why you passed user not users

  11. Alex Kovry
    January 17, 2019 at 01:48

    cool. you are the best! thx!

  12. Эд Лесничий
    January 17, 2019 at 01:48

    admin.deleteUser(admin) ☠️

  13. DwinaTech
    January 17, 2019 at 01:48

    What is theme name are using?

  14. Nelson Ongiti
    January 17, 2019 at 01:48

    Hey Ninja i wouldlike it if you revisted this topic thank you

  15. Nelson Ongiti
    January 17, 2019 at 01:48

    admin.deleteUser IS NOT A FUNCTION
    class User{

    // inside the class create a constructor to help us create object instances

    constructor(name, email, score){

    //set constructor properties

    this.name = name;

    this.email = email;

    this.score = 0;

    }

    //class methods are written outside the constructor but inside the class

    login(){

    console.log(this.email, 'Welcome …….loggedIn');

    return this;

    }

    logout(){

    console.log(this.email, 'Bye Now……..loggedOut');

    return this;

    }

    updateScore(){

    this.score++

    console.log(this.email, 'Score is Now', this.score);

    return this;

    }

    }

    class Admin extends User{

    deleteUser(user){

    users = users.filter(u => {

    return u.email != user.email

    });

    }

    }

    var userOne = new User('Nelson','nelson@gmail.com');

    var userTwo = new User('machoka','machoka@gmail.com');

    var userThree = new User('momo','momo@gmail.com');

    var admin = new User('mekenzi','mekenzi@gmail.com');

    //delete user

    var users = [userOne, userTwo, userThree];

    admin.deleteUser(userOne);

    console.log(users);

  16. Juraj Pecháč
    January 17, 2019 at 01:48

    You deleted userOne only from array users., userOne exists henceforth.

  17. Spark
    January 17, 2019 at 01:48

    I am the 1000th viewer yayyyy!!!

  18. azzam hamzeh
    January 17, 2019 at 01:48

    class Admin extends User{
    deleteUser(user){
    users = users.filter(u => {
    return u.email != user.email;
    });
    }
    }
    TypeError: Admin.deleteUser is not a function
    why??

  19. natqe
    January 17, 2019 at 01:48

    Why you're using the var keyword instead of let or const?

  20. David Eugene
    January 17, 2019 at 01:48

    Salut et merci 🙂

    Today, I have a little question:

    Why do we see [User, User, Admin] (class names) when we make a console.log (users) instead of [userOne, userTwo, admin] (the names of the variables)?
    The names of the variables no longer appear, even when we are doing 'users [0]' in the console.

    Thanks in advance

  21. Rhyand
    January 17, 2019 at 01:48

    Super helpful, thanks a ton Shaun! Being a newbie, I do have a general question about the code here. The deleteUser() method seems to only except the user as an argument instead of the user and users even though the method needs both to work. I'm assuming that's because the users array in global scope? Also, would there be any benefit/best practice to explicitly require the users array as an argument? e.g deleteUser(user, users)

  22. HabelFoc _
    January 17, 2019 at 01:48

    i would loved if you make "Real world projects" based tutorial on Udemy using JavaScript/Nodejs/ReactJs technologies 🙂

  23. Chon Hee Cho
    January 17, 2019 at 01:48

    "Inherit"(or "extends") is simple and useful. Your explanation is the best as well. Thanks!

Leave A Comment

You must be logged in to post a comment.