Last active
March 17, 2021 03:14
-
-
Save dhruv-m-patel/e1990738f81d2ece3d9f06b06d6f45b4 to your computer and use it in GitHub Desktop.
JS Code Samples
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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