LLD - Behavioral Design Patterns — Part 2
Given the following code snippet, what will be the output?
class ElementA {
accept(visitor) {
visitor.visit(this);
}
}
class PrintVisitor {
visit(element) {
console.log('Visited element');
}
}
const element = new ElementA();
const visitor = new PrintVisitor();
element.accept(visitor);