Skip to content

Instantly share code, notes, and snippets.

@heymichaelp
Last active August 29, 2015 14:02
Show Gist options
  • Save heymichaelp/6dabe0f93b2e3302d0d8 to your computer and use it in GitHub Desktop.
Save heymichaelp/6dabe0f93b2e3302d0d8 to your computer and use it in GitHub Desktop.
Value Objects: Example of Functional approach
Grade.equal = function(grade1, grade2) {
return grade1.valueOf() === grade2.valueOf();
}
var myFirstGrade = new Grade(0.7);
var mySecondGrade = new Grade(0.7);
Grade.equal(myFirstGrade, mySecondGrade) // => true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment