Reputation: 1747
Is there any reason why I should consider not using 'use strict' in a node module published via npm? Is it 'safe' to do that if I want others to be able to use it?
EDIT: I asked this question explicitly to find out, if it can make the module useless/broken for anybody who wants to install it via npm.
Upvotes: 3
Views: 2023
Reputation: 95066
'use strict';
enforces a set of rules on your code. If ran in an environment that doesn't support 'use strict';
, it is simply ignored, no harm done.
It will only apply to your code, assuming it is not concatenated with anyone else's code (unless you're using it inside of a function rather than outside, in which case it would only affect that function, even if concatenated.)
Therefore, Yes, it is safe to use 'use strict';
in a piece of code without fear of it causing problems for other people using your code. I would even go as far as saying it is recommended.
Upvotes: 6