Bird
0
0

Given this pseudocode snippet, what will be printed after a config update triggers the callback?

medium📝 Analysis Q4 of 15
Microservices - Configuration and Secrets Management
Given this pseudocode snippet, what will be printed after a config update triggers the callback?
config = {"mode": "prod"}
function onConfigChange(newConfig) {
  config = newConfig
  print(config["mode"])
}
// Config update arrives
onConfigChange({"mode": "dev"})
Aprod
Bdev
Cundefined
Derror
Step-by-Step Solution
Solution:
  1. Step 1: Analyze initial config and callback

    Initial config mode is "prod" but callback replaces it with newConfig.
  2. Step 2: Check what callback prints

    Callback prints newConfig["mode"] which is "dev".
  3. Final Answer:

    dev -> Option B
  4. Quick Check:

    Callback prints updated config mode [OK]
Quick Trick: Callback prints new config value after update [OK]
Common Mistakes:
  • Printing old config instead of new
  • Assuming undefined because of variable scope
  • Expecting error due to missing keys

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Microservices Quizzes