Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
JS Code Samples
// What would be the outcome of this statement?
const [a, b] = [10, 20];
// What is the "..." in following statement? What does it do?
const [a, b, ...rest] = [10, 20, 30, 40, 50];
// What is this statement doing?
const { a, b } = response;
// What would be the result of the following statements?
const response = {
a: null,
b: {
x: "foo"
}
};
const {
a = 10,
b: output
} = response;
// What is the "?." called in here? What does it do?
if (a.b?.c?.d) {
..........
}
// What is the "??" operator called? What does it do?
const a = b ?? c;
// What would be the end result of the following?
const a = 10;
const b = 5;
const c = 20;
const d = (x) => x * 10;
const result = [a, b, c].map(d);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment