Bird
0
0

Identify the bug in this dynamic config update code snippet:

medium📝 Analysis Q6 of 15
Microservices - Configuration and Secrets Management
Identify the bug in this dynamic config update code snippet:
config = {"feature": false}
function updateConfig(newConfig) {
  config = {...config, newConfig}
}
updateConfig({"feature": true})
print(config["feature"])
AMissing callback registration
BIncorrect object spread syntax
CConfig variable not declared
DPrint statement before update
Step-by-Step Solution
Solution:
  1. Step 1: Review object spread usage

    The syntax {...config, newConfig} nests newConfig as an object instead of merging keys.
  2. Step 2: Correct syntax for merging

    Should use {...config, ...newConfig} to merge keys properly.
  3. Final Answer:

    Incorrect object spread syntax -> Option B
  4. Quick Check:

    Spread operator must merge keys correctly [OK]
Quick Trick: Use ...newConfig to merge objects, not newConfig alone [OK]
Common Mistakes:
  • Using newConfig without spread operator
  • Ignoring callback registration importance
  • Assuming print order causes error

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Microservices Quizzes