DWQA QuestionsCategory: ProgramConst {printname} = logger what does it mean to define variables in the form of braces?
Blue with black asked 4 weeks ago

What does it mean to define variables in the form of braces?

const { printName } = logger

,

let { foo, bar } = { foo: "aaa", bar: "bbb" };
foo // "aaa"
bar // "bbb"

Object deconstruction assignment,The new syntax for ES6 is calleddeconstruction

const { printName } = logger

be equal to

const printName = logger.printName;
joyqi replied 4 weeks ago

I’ll delete it if I don’t add any more

joyqi replied 4 weeks ago

Please use the comment function

joyqi replied 4 weeks ago

Questions should be put in comments, not in answers.

joyqi replied 4 weeks ago

@fenYes, it is executed at the terminal

joyqi replied 4 weeks ago

Please ignore this clause

2 Answers
RandyO answered 4 weeks ago
let { foo, bar } = { foo: "aaa", bar: "bbb" };
foo // "aaa"
bar // "bbb"

Object deconstruction assignment

Clark answered 4 weeks ago

The new syntax for ES6 is calleddeconstruction

const { printName } = logger

be equal to

const printName = logger.printName;