JavaScript · Middle · Question 32 of 75

What does this code print?

const cfg = Object.freeze({ db: { host: "a" } });
cfg.db.host = "b";
console.log(cfg.db.host);

Explanation

Object.freeze prevents adding, removing and changing properties of the object itself only. Nested objects remain mutable. Deep freezing is done with a recursive function.

Further reading

Problem with a question

JavaScript · Middle · question 32

Test yourself

Take the JavaScript · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz