


It all comes down to two properties, amount and currency, and several expected operations, including _+, -, *, /, >, >=, <, <=, and =. Since 2002, when Martin Fowler released his acclaimed book titled Patterns of Enterprise Application Architecture, we have a great model to deal with monetary values. Commons Pitfallsīefore we dive into the pitfalls, let's first understand what is required to perform monetary calculations. In this article, we will explore these common pitfalls in greater detail and the best options to deal with money in JavaScript. And it's been like that for a long time.īecause of the lack of representativity, money types are handled in many different ways, depending on the language you're using. What happened to the money, then? Banks, brokers, online shopping, etc. How many ways to deal with dates and times do they have? Most of them will probably release at least one way to deal with such data types because it is a very present type in a developer's programming life. Think about all the programming languages you've worked with before.

One of the most curious things about modern programming languages is that when someone decides to create a new one, lots of thinking about the accepted data types and internal auxiliary libraries takes place.
