How to get bar out of cagingIt using destructuring?
let cagingIt = {
foo: {
bar: 'Nick Cage'
}
};
let { foo: {bar: name} } = cagingIt;
console.log(name); // "Nick Cage"
In this example, foo
is referring to the property name "foo". Following the colon, we then use bar
which refers to the property "bar". Finally, name
acts as the variable storing the value.
Consider that destructuring is not null-safe so it is risky to use this way.
How to get bar out of cagingIt using destructuring?
let cagingIt = {
foo: {
bar: 'Nick Cage'
}
};
How to get bar out of cagingIt using destructuring?
let cagingIt = {
foo: {
bar: 'Nick Cage'
}
};
let { foo: {bar: name} } = cagingIt;
console.log(name); // "Nick Cage"
In this example, foo
is referring to the property name "foo". Following the colon, we then use bar
which refers to the property "bar". Finally, name
acts as the variable storing the value.
Consider that destructuring is not null-safe so it is risky to use this way.
status | not learned | measured difficulty | 37% [default] | last interval [days] | |||
---|---|---|---|---|---|---|---|
repetition number in this series | 0 | memorised on | scheduled repetition | ||||
scheduled repetition interval | last repetition or drill |