O'Reilly logo

JavaScript Domain-Driven Design by Philipp Fehre

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Value objects

When dealing with objects in various languages, including JavaScript, objects are almost universally passed and compared by reference, which means that an object that is passed to a method does not get copied, but rather its pointer gets passed, and when two objects are compared, their pointers are compared. This is not how we think about objects and especially value objects, as we think of those as identical if their properties are identical. More importantly, we don't want to consider the inner implementation details when we consider things like equality. This has some implications for the function using the object; one important implication is that modifying the object will actually change it for everybody in the system, for example: ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required