---
# System prepended metadata

title: Builder Design Pattern Example in Javascript

---

# Builder Design Pattern Example in Javascript

Here, it's shown how a complex "User" object has been made from various differnet types of simple objects. Though it can be done in many ways, but using builder design pattern is more beautiful way to make this code more reusable . **Code Starts below**

```any=
class Address {
  constructor(street,area) {
    this.street = street
    this.area = area
  }
}

class User {
  constructor(name, { age, mobile, address } = {}) {
    this.name = name
    this.age = age
    this.mobile = mobile
    this.address = address
  }
}

let user = new User('Rhythm', { address: new Address('131/1', 'Mirpur-1') })
```