LLD - Behavioral Design Patterns — Part 2
Consider this code snippet using Null Object pattern:
What will be the output when this code runs?
class Logger {
log(message) { console.log(message); }
}
class NullLogger {
log(message) { /* do nothing */ }
}
function process(data, logger) {
logger.log('Start');
// process data
logger.log('End');
}
const logger = new NullLogger();
process('input', logger);What will be the output when this code runs?
