Hints and tips

Here are a couple of brief tips to keep in mind about some of the patterns we've seen in this chapter:

  • When implementing the interpreter pattern, you may be tempted to use JavaScript properly as your DSL and then use the eval function to execute the code. This is actually a very dangerous idea as eval opens up an entire world of security issues. It is generally considered to be very bad form to use eval in JavaScript.
  • If you find yourself in a position to audit the changes to data in your project, then the memento pattern can easily be modified to suit this. Instead of just keeping track of the state changes, you can also track when the change was made and who made the change. Saving these mementos to disk somewhere allows you to ...

Get Mastering JavaScript Design Patterns now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.