I read the last of the “Don't Know JS” series and am completely lost when it comes to the destructive part. Please help me understand the fragment here, please. The context here is about to put some specific configurations into effect, while other values are still available.
default values:
var defaults = {
options: {
remove: true,
enable: false,
instance: {}
},
log: {
warn: true,
error: true
}
};
config:
var config = {
options: {
remove: false,
instance: null
}
};
how the author reaches
config.options = config.options || {};
config.log = config.log || {};
({
options: {
remove: config.options.remove = defaults.options.remove,
enable: config.options.enable = defaults.options.enable,
instance: config.options.instance =
defaults.options.instance
} = {},
log: {
warn: config.log.warn = defaults.log.warn,
error: config.log.error = defaults.log.error
} = {}
} = config);
and the author made such a description about the fragment:
, Im destructuring defaults === undefined . , Im destructuring config (. = config ), Im , config.options.enable .
: config.options.enable. config.options.enable config.options?
? !