How it works...

MarsMissionFactory receives the values for the name and rocket properties of mission, then supplies the remaining values to a builder instance. This narrows the properties required to make a new mission, while still using the builder interface.

This method of combining rather than modifying patterns is preferable in many use cases. Like more established library code, better-known patterns have better-defined contracts and more predictable behavior than custom ones. Their familiarity makes them easier for a newcomer to understand.

Get ECMAScript Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.