How to get the counts out of cagingIt as ct1, ct2, ct3 using destructuring in javascript?
let cagingIt = {
foo: {
bar: 'Nick Cage',
counts: [1, 2, 3]
}
};
let { foo: {counts: [ ct1, ct2, ct3 ]} } = cagingIt;
console.log(ct2); // prints 2
In this example, foo
is referring to the property name "foo".
Following the colon, we then use counts which refers to the property "counts".
Then use array destructuring and store those values as well.
Consider that destructuring is not null-safe so it is risky to use this way.
How to get the counts out of cagingIt as ct1, ct2, ct3 using destructuring in javascript?
let cagingIt = {
foo: {
bar: 'Nick Cage',
counts: [1, 2, 3]
}
};
How to get the counts out of cagingIt as ct1, ct2, ct3 using destructuring in javascript?
let cagingIt = {
foo: {
bar: 'Nick Cage',
counts: [1, 2, 3]
}
};
let { foo: {counts: [ ct1, ct2, ct3 ]} } = cagingIt;
console.log(ct2); // prints 2
In this example, foo
is referring to the property name "foo".
Following the colon, we then use counts which refers to the property "counts".
Then use array destructuring and store those values as well.
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 |