Object-oriented Programming in JavaScript: Made Super Simple | Mosh



🔥Get the COMPLETE course (70% OFF – LIMITED TIME): http://bit.ly/2keDCna

Object-oriented programming in JavaScript: learn all about objects, prototypes, prototypical inheritance, this and more.

Subscribe for more videos:
https://www.youtube.com/channel/UCWv7vMbMWH4-V0ZXdmDpPBA?sub_confirmation=1

TABLE OF CONTENT:

00:00: What is OOP?
01:46: Four Pillars of OOP
08:50: Setting Up the Development Environment 11:07: Objects
11:53: Object Literals
14:58: Factories
17:50: Constructors
23:27: Constructor Property
25:53: Functions are Objects
31:09: Value vs Reference Types
37:00: Adding or Removing Properties
40:54: Enumerating Properties
43:45: Abstraction
47:48: Private Properties and Methods
51:55: Getters and Setters
57:32: Exercise
59:42: Solution

Want to learn more from me? Check out my blog and courses:

http://programmingwithmosh.com
https://www.facebook.com/programmingwithmosh/

41 thoughts on “Object-oriented Programming in JavaScript: Made Super Simple | Mosh

  1. What does actually happen when we set private property f.e.: 'defaultLocation' on an object and from the outside, when the setter for it was not yet defined? I was expecting an error, but I didn't get any. The effect is that property was just not set, but what is the logic behind it?

  2. Great video Mosh.
    However you don't actually talk about ES6 OOP, like ES6 classes, ES6 getters and setters, inheritance, static properties and methods.. Is there any specific reason for that? Are they explained later in the course?

  3. (dont judge me if this is a dumb question im new to programming) how/why does vscode highlight on the left next to the line number for you, doesn't do that for me

  4. I have come across many very smart coders in my time in the industry. Talk about some of the cleverness! But few can explain it to a regular like me. There were moments here that also I could say there was a jump. But there were 2 for me. For regulars like me js objects and functions and scope is tricky. I used to do actionscript and as3 seemed to get there before es6! There are certainly a lot of things here that as3 did first AFAIK. An example is the call and apply and when why would they be used. To throw the scope and perform a function on a different scope. I think it's part of polymorphism. I used this as a refresher and I actually learned NEW stuff. Great video. clap clap clap.

  5. This is my solution on the exercise:

    function StopWatch() {

    let duration = 0;

    let status = false;

    let interval;

    this.counter = function() {

    duration += 0.1;

    }

    Object.defineProperty(this, "duration", {

    get: function() {

    return Math.round(duration * 100) / 100;

    }

    })

    this.reset = function() {

    duration = 0;

    }

    this.start = function() {

    if (status === true){

    throw new Error('Status is already on!')

    }else {

    interval = setInterval(this.counter, 100);

    status = true;

    }

    }

    this.stop = function() {

    if (status === false){

    throw new Error('Status is already off!')

    }else {

    clearInterval(interval);

    status = false;

    }

    }

    }

  6. TABLE OF CONTENT:

    00:00: What is OOP?

    01:46: Four Pillars of OOP

    08:50: Setting Up the Development Environment
    11:07: Objects

    11:53: Object Literals

    14:58: Factories

    17:50: Constructors

    23:27: Constructor Property

    25:53: Functions are Objects

    31:09: Value vs Reference Types

    37:00: Adding or Removing Properties

    40:54: Enumerating Properties

    43:45: Abstraction

    47:48: Private Properties and Methods

    51:55: Getters and Setters

    57:32: Exercise

    59:42: Solution

    Because they are broken in the description

  7. guys, I really want to take the full course but I don't have the money to pay for it like seriously I don't have.
    Is by any chance can someone buy it for me and ill be thankful forever.

  8. timestamps….. but it works

    00:00: What is OOP?

    01:46 Four Pillars of OOP

    08:50 Setting Up the Development Environment
    11:07 Objects

    11:53 Object Literals

    14:58 Factories

    17:50 Constructors

    23:27 Constructor Property

    25:53 Functions are Objects

    31:09 Value vs Reference Types

    37:00 Adding or Removing Properties

    40:54 Enumerating Properties

    43:45 Abstraction

    47:48 Private Properties and Methods

    51:55 Getters and Setters

    57:32 Exercise

    59:42 Solution

    the one in the description didnt work for me

  9. Thank you for taking time to make this tutorial that clears the OOP concepts so nicely and followed by that small, but interesting, exercise. Now my JavaScript base is ready. This is such a precious tutorial for beginners.

  10. function Demo2(firstname){

    this.firstname = firstname

    let lastname = "Jobs"

    let combine = function(){

    console.log("Full Name:"+this.firstname+" "+lastname)

    }

    this.maincall = function(){

    combine()

    }

    }

    let obj = new Demo2("Steve")

    obj.maincall()

    In combine function why I cannot able to access firstname variable using -> this <- keyword? (output:- Full Name: Undefined Jobs )

    and if I use firstname without this keyword then it shows the perfect output.

Leave a Reply

Your email address will not be published. Required fields are marked *