Question from the Javascript test

Accessing nested object properties in Javascript

Hard

What will the following code display:

let myObj = {
    a : 'A',
    b : 'B',
    c : {
        d : 'D',
        e : 'E',
        f : {
            g : 'G'
        },
        h : 'H'
    }
};

let { c : { f : { g: foo}, e: baz, b: bar }  }= myObj;

console.log(foo, bar, baz);
Author: Jean-marie CléryStatus: PublishedQuestion passed 1879 times
Edit
0
Community Evaluations
developer avatar
Spelling / formatting error
Justin
07/05/2024
One liners for objects are unreadable