Skip to main content

Posts

Showing posts from May, 2022

Advanced Objects Introduction in JS

  Advanced Objects Introduction Remember, objects in JavaScript are containers that store data and functionality. In this lesson, we will build upon the fundamentals of creating objects and explore some advanced concepts. So if there are no objections, let’s learn more about objects! In this lesson we will cover these topics: how to use the this keyword. conveying privacy in JavaScript methods. defining getters and setters in objects. creating factory functions. using destructuring techniques. The this Keyword Objects are collections of related data and functionality. We store that functionality in methods on our objects: const goat = {    dietType : 'herbivore' ,    makeSound () {      console . log ( 'baaa' );   } }; In our  goat  object we have a  .makeSound()  method. We can invoke the  .makeSound()  method on  goat . goat . makeSound (); // Prints baaa Nice, we have a  goat  ob...