Javascript Optional Chaining
Javascript Optional Chaining
Optional Chaining
1
2
3
4
5
6
7
8
9
10
11
12
13
const adventurer = {
name: "Alice",
cat: {
name: "Dinah"
}
}
function* createName() {
return "12"
}
console.log(adventurer.dog?.name);
// undefined
1
2
adventurer.dog?.name = createName()
// Error: Left side of assignment is not a reference.
This post is licensed under CC BY 4.0 by the author.