Basically every tutorial I’ve watched on Node.js, and even the express generator has all variables declared using var
instead of let
? From what I’ve learned in Javascript.info let
should be the standard unless for very niche cases.
It is because the Node.JS code is written in ES5 which does not support the use of let and const. If you still wish to write your code in ES6, you need to use something called Babel which will help Node.JS to convert the ES6 code into ES5. But you can definitely use let and const in Node. I hope the answer helps.
Please refer to the below link for an in-depth explanation. https://dev.to/dhruv/writing-es6-in-your-nodejs-applications-33jk
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With