I learned of Electron only earlier today, and after a little trial-and-error succeeded in downloading and running “electron-quick-start”, and then in modifying it to change functionality and to bring it into line with my own coding conventions. But I am completely bemused by the line “let mainWindow”. I understand from the accompanying notes that this may have something to do with keeping the window alive after garbage collection, but I neither understand the syntax nor the semantics of that line. Could anyone explain, please ?
Welcome on Electron !
mainWindow is an variable that you will have need used in your “main” and “renderer”
Good luck for your projects with Electron
Many thanks, Shmuel. In fact, it was not the use of “mainWindow” that mystified me, but rather the use of "let " without a following assignment. However, I now see from an example at putaindecode.io that a bare "let " construction is permitted (“let foo // that’s ok (foo === undefined)”), so all is now clear, but from the perspective of clarity I would personally have coded that line as “let foo = undefined”. Brevity may have its place, but clarity is (or should be) essential.
let a = undefined you get an error:
It’s not necessary to initialize ‘a’ to undefined.
With respect, I would not interpret that message as an error message. On a scale of 1 to 5 (success, information, warning, error, fatal error), I would class that as a 1 (informational). The statement says it is unnecessary — it doesn’t say it is wrong.