i’m learning electron’s docments by myself. in this example
https://fiddle.electronjs.org/launch?target=electron/v26.1.0/docs/fiddles/tutorial-preload
https://github.com/electron/electron/tree/v26.1.0/docs/fiddles/tutorial-preload
i tried to add an optional chaining operator in renderer.js like this
const information = document.getElementById('info')
information.innerText = `This app is using Chrome (v${window.versions.chrome()}), Node.js (v${window.versions.node()}), and Electron (v${window.versions.electron()})`
to
const information = document.getElementById('info')
information?.innerText = `This app is using Chrome (v${window.versions.chrome()}), Node.js (v${window.versions.node()}), and Electron (v${window.versions.electron()})`
but the versions info disappears.
i’m using electron v26.1 so nodejs version is 18. i checked node.green it says node18 has implements all optional chaining operator functions. why is this unfunctional? thanks in advance
>Solution :
You can’t make use of optional chaining on the left hand side of an assignment. For instance –
let a = { b: 1 };
a?.b = 4; // Throws SyntaxError: Invalid left-hand side in assignment
a.b = 4; // No error
Check MDN Reference for more information.