22: How to Create Object Constructors | Object Constructors in JavaScript | JavaScript Tutorial




In this JavaScript tutorial you will learn about object constructors which are used to create multiple instances of an object. We use this in JavaScript when we need to create copies of an object in a way that doesn’t require us to create a new object each time.

In the next video I will create a “game” project where we will create a RPG/Battle style game in the browser using JavaScript.

➤ CHECK OUT THESE AWESOME PEOPLE!

Meet Daniel: another Full-Stack developer who can teach you coding fast and free 😀
https://www.youtube.com/channel/UCPIe87uLDW-QZ5FnUZqdxoA

➤ GET ACCESS TO MY LESSON MATERIAL HERE!

First of all, thank you for all the support you have given me!

I am really glad to have such an awesome community on my channel. It motivates me to continue creating and uploading content! So thank you!

I am now using Patreon to share improved and updated lesson material, and for a small fee you can access all the material. I have worked hard, and done my best to help you understand what I teach.

I hope you will find it helpful 🙂

Material for this lesson: https://www.patreon.com/posts/javascript-22-19543291

Original source


32 responses to “22: How to Create Object Constructors | Object Constructors in JavaScript | JavaScript Tutorial”

  1. function Person(name, age, color){
    this.name= name;
    this.age= age;
    this.color= color;

    this.updateAge= function(){
    return ++ this.age;
    };

    }
    let person1 = Person("a", 12, "white");
    let person2 = Person("b", 25, "bkack");
    console.log(person1.updateAge());

    i wrote this cant run it says undefine function pls help

  2. Hello Daniel, you are doing an amazing job here! Thank you so much. You are one of the best online tutor i have ever come across! I am enjoying this tutorial a whole lot. I can wait till we are done to see how much i will be able to learn under your tutelage!

  3. Daniel, you are really a great teacher. you understand what its like to be seeing some of this stuff for the first time and that is great. seems like javascript has changed a lot over the past couple of years. at once it seemed all about events and updating web pages. objects was one of those things people never talked much about in a beginners class. The whole idea of JS is sorta like and endless journey. it make me feel like no matter what we learn, there is always more. when does a person know JS….that is a question you should do a video on in my opinion. what is the end goal so to speak.
    var js= 5150
    if (js == 5150)

    {alert( "the boy's mind got hung in an endless loop ");}

    else{alert( "all is well that ends well");}

Leave a Reply