Skip to main content

9 topics · 0/9 read

JavaScript Part 4 (OOP)

Object-Oriented Programming concepts including Factory Functions, Constructors, Classes, Prototypes, and Inheritance

  1. Factory Functions

    A factory function is a function that returns a new object. It is a simple way to create multiple objects with shared properties and methods without using classes or constructors.

    Read now
  2. Constructor Functions

    A constructor function is a function used to create objects and is invoked with the `new` keyword. It automates object creation and initializes properties.

    Read now
  3. ES6 Class Constructors

    ES6 introduces the `class` keyword as syntactic sugar over constructor functions. It provides a cleaner and more readable way to create objects and handle inheritance.

    Read now
  4. prototype

    The `prototype` is an object associated with every function and object in JavaScript. It is used to share methods and properties among instances of an object, reducing memory usage.

    Read now
  5. Object.create()

    The `Object.create()` method creates a new object with the specified prototype and properties.

    Read now
  6. setPrototypeOf() and getPrototypeOf()

    `Object.setPrototypeOf()` sets the prototype of an object, while `Object.getPrototypeOf()` retrieves the prototype of an object.

    Read now
  7. constructor.prototype.key = value

    Adding methods or properties to a constructor function's prototype makes them accessible to all instances created by that constructor.

    Read now
  8. ES6 Class Methods and Prototypes

    Methods written in ES6 class syntax are automatically added to the `prototype` of the class, ensuring shared access among instances.

    Read now
  9. __proto__

    `__proto__` is an internal property available on all objects in JavaScript. It is a reference to the prototype of the object. It provides access to the prototype chain, which is the mechanism JavaScript uses to inherit p

    Read now