Getter and setter properties in JavaScript

Поделиться
HTML-код
  • Опубликовано: 5 май 2021
  • In this lecture, you will learn, what is getter and setter properties are and how to use them in your JavaScript program. Getter and setter properties were introduced with the release of ECMAScript 5.

Комментарии • 15

  • @Jack57098
    @Jack57098 4 месяца назад +1

    One of the most well explained videos that I have seen and I have seen a lot of videos. Really appreciate it. It is a shame that this channel's videos have gotten so much less views.

  • @Ansha-xq1uy
    @Ansha-xq1uy 8 месяцев назад

    Watched the first few youtube recommendation for getter and setter which made me more chaotic ..THIS WAS CRYSTAL CLEAR .THANKS BROTHER . KEEP GOING

  • @xpantia
    @xpantia Год назад +1

    Best tutorial about getter setter out of the several videos I watched. Thank you!

  • @kartickchandramanna267
    @kartickchandramanna267 9 месяцев назад

    Best lecture, After searching lot of lectures , I find this. Thank you 🙏

  • @ismatsalmanov7574
    @ismatsalmanov7574 Год назад +3

    Danke!

  • @clickherenow9946
    @clickherenow9946 2 года назад +1

    You made it super easy to understand. Thanks for the video. God bless you

  • @MoneymakerGrowingFast
    @MoneymakerGrowingFast 8 месяцев назад

    That's literaly the best video i've seem about getters and setters on javascript. Thanks man!

  • @dyracho6667
    @dyracho6667 2 года назад

    you made it so easy to understand. Thank you for your hard work , sir.

  • @ndatech9549
    @ndatech9549 8 месяцев назад

    this channel is a gold

  • @iambrijeshtoo
    @iambrijeshtoo Год назад

    Thank you ❤

  • @dyracho6667
    @dyracho6667 2 года назад

    Sir, I cannot have either get or set property alone. Although I only write get method for company , I can still set as User.company = 'abc' and company changed.

  • @farazk9729
    @farazk9729 Год назад

    Hi,
    I am new to programming, but as far as I know, in langauges like C#, you can make a property private, i.e., truly encapsulate it, hence making the use of getters and setter a NECESSITY, but here why would I NEED to use getters and setters when I can easily access and modify the properties? You said there are two reasons:
    1) Encapsulation
    2) When you modify/calculate a value.
    The second one makes sense, but you didn't give an example for the first one: how can you hide your data from the world when you can't make it private? Or maybe you can?
    Thanks,

    • @Saif.x
      @Saif.x 10 месяцев назад +3

      To hide the properties of the class or to make the properties of class private we use _ sign with properties.
      For example: constructor(name,password){
      this._name=name;
      this._password=password;
      }
      Now name and password properties are private and we can use get and set methods to perform operations on it indirectly

  • @slobodantajisic2762
    @slobodantajisic2762 4 месяца назад

    All properties in this tutorial are public, so we always have access to them. How to make properties in JavaScript private?

    • @MysticDepth07
      @MysticDepth07 19 дней назад

      JavaScript isn't a language like c, java or c++. The variables in JavaScript are determined private and public by the let and val keyword. let for private and val for public.