What is the primary advantage of using composition over inheritance in ES6?
- Code Reusability
- Tight Coupling
- Polymorphism
- Encapsulation
In ES6, composition refers to combining simpler functions or objects to create more complex ones. The primary advantage is improved code reusability and flexibility, as it avoids the issues associated with tight coupling in inheritance. Composition promotes a more modular and maintainable code structure, allowing for better adaptability to changes.
Loading...
Related Quiz
- How are escape sequences like n treated in template literals?
- What is the base case in a recursive function?
- The _________ method in Promise chaining is used to catch any errors that occur during the execution of the promise.
- When importing a module without specifying a subpath, ES6 will by default look for a file named ________.
- To pause and resume a generator function, the _________ keyword is used within the function body.