19
rated 0 times
[
22]
[
3]
/ answers: 1 / hits: 8647
/ 4 Years ago, sat, september 19, 2020, 12:00:00
I literally copy pasted example code from MDN but optional chaining wont work in my node(v12.13.0) REPL. Throws out a syntax error saying that the dot after the question mark is invalid. What's going on ? I have already used this expression in a React App and it seems to be working fine.
const adventurer = {
name: 'Alice',
cat: {
name: 'Dinah'
}
};
const dogName = adventurer.dog?.name;
console.log(dogName);
// expected output: undefined
console.log(adventurer.someNonExistentMethod?.());
// expected output: undefined
More From » node.js