Skip to content

Instantly share code, notes, and snippets.

@Winwardo
Created July 18, 2015 11:57
Show Gist options
  • Save Winwardo/c9494b3253553ababdae to your computer and use it in GitHub Desktop.
Save Winwardo/c9494b3253553ababdae to your computer and use it in GitHub Desktop.
var StudentClass = function(){
this.name = "Some default name";
this.age = undefined;
this.address = {};
};
var StudentClassBuilder = new BuilderDecorator(StudentClass);
var student = new StudentClassBuilder()
.name("John")
.age(17)
.address({postcode: "90210"})
.build();
student.name(); // "John"
student.age(); // 17
student.address(); // {postcode: "90210"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment