Node.js: when to use 'use strict'


#1

Question:

I know that for node.js v10.12.0, 'use strict'; is no longer necessary when using let, const, etc. However, is it considered best practice to still include that instruction at the top of the script for backward compatibility?


#2

Yes, that’s the main reason I went with those in the book, and I didn’t really investigate how adding that changes the code. I’d say if you stick to the modern style in the book then don’t bother. But if you have to adopt some code in an older style then adding that to the top can help. I do know that this has it’s own set of problems though.