← Back to design patterns map
Design Pattern

Visitor

Add operations to object structures without changing those objects.

behavioral

Visual Diagram

Visitor
-> visitUser()
-> visitOrder()
-> visitInvoice()

When To Use

  • ->AST transforms
  • ->Linting rules
  • ->Tree traversal with many operations
  • ->Exporting different object types
Used in: AST transforms, Babel plugins, tree walkers
visitor.js

Live Editor

Loading...

Output

Run code to see output...

Comments

Sign in to leave a comment. Your name and photo come from Google; nothing else is shared.

Loading comments...