Skip to main content
Stack Overflow
  1. About
  2. For Teams

Timeline for How is the 'use strict' statement interpreted in Node.js? [duplicate]

Current License: CC BY-SA 3.0

Post Revisions

25 events
when toggle format what by license comment
Sep 23, 2021 at 18:04 comment added UpTheCreek How is this a duplicate of that referenced question? People got a bit gung ho here.
May 20, 2020 at 15:57 review Reopen votes
May 21, 2020 at 0:06
Jun 23, 2017 at 12:47 comment added fider @AmolMKulkarni : *note that Node JS wraps our code (module) into function (function (exports, require, module, __filename, __dirname, process, global) { .. your module code }); and then it is processed by V8
Dec 17, 2016 at 11:49 history edited Peter Mortensen CC BY-SA 3.0
Copy edited. Removed meta information (this belongs in comments).
Feb 27, 2015 at 14:04 comment added Michael Merchant I'm not sure this was a duplicate. This question was useful in helping me understand that node.js is interpreted using the same engine as the Chrome Browser. Without that knowledge, there's limited clarity on how "use strict" is applied.
Sep 10, 2013 at 15:57 review Reopen votes
Sep 10, 2013 at 16:08
Aug 24, 2013 at 12:15 vote accept Community Bot
S Aug 24, 2013 at 11:40 history suggested Amol M Kulkarni CC BY-SA 3.0
improved some contents
Aug 24, 2013 at 11:32 review Suggested edits
S Aug 24, 2013 at 11:40
Aug 24, 2013 at 11:30 history closed Eric
Felix Kling
Paul
millimoose
Bergi
Duplicate of What does "use strict" do in JavaScript, and what is the reasoning behind it?
Aug 24, 2013 at 10:37 comment added Fabrício Matté Yep, IIFEs for scoping are very useful in front-end JS otherwise any var/function declarations would be unnecessarily thrown in the global scope. Though Node.js doesn't have that problem, you have to manually export vars/functions through module.exports (or global shivers) so scoping isn't that much of an issue on Node. Well, too sleepy to keep up, night. :P
Aug 24, 2013 at 10:31 review Close votes
Aug 24, 2013 at 11:31
Aug 24, 2013 at 10:30 comment added Golo Roden Yep, and as mentioned before: It's good practice for various other reasons, such as scoping, creating modules & co.
Aug 24, 2013 at 10:30 answer added Amol M Kulkarni timeline score: 213
Aug 24, 2013 at 10:29 comment added Fabrício Matté @GoloRoden +1 for the IIFE. That's what I do for all my JS files and is also recommended by JS[H|L]int from what I remember.
Aug 24, 2013 at 10:28 comment added Golo Roden As you already said: Problems may arise when you concatenate all your script files. Hence I'd consider it a no-go, and would - as rule of thumb - recommend that you always wrap your code in an immediately executed function (which is a good idea, anyway, for various other reasons). In Node.js, that's simply not neccessary.
Aug 24, 2013 at 10:27 comment added Golo Roden Exactly. Nevertheless, there's that difference between web browsers and Node.js: In one scenario you should think about it, in the other you don't need to. (My comment regarding sarcasm was not related to you, btw)
Aug 24, 2013 at 10:26 review First posts
Aug 24, 2013 at 10:28
Aug 24, 2013 at 10:26 comment added Fabrício Matté @GoloRoden though I refrain from using it file-wide, MDN says it works as intended when setting 'use strict'; file-wide. Problems arise when you concatenate non-strict with strict files, or when you set use strict inside an HTML page's inline script tag (which Node does not have).
Aug 24, 2013 at 10:22 comment added Golo Roden Yes, and although Node.js is JavaScript, there's a subtle difference in how to use strict mode: In Node.js it's no problem to do enable it file-wide, outside of an immediately executed function, in the browser that's a no-go. So, at least IMHO no need for sarcasm.
Aug 24, 2013 at 10:20 comment added Fabrício Matté The files which you've seen probably have a .js extension as well. That's the language which Node runs (its JS interpreter being V8).
Aug 24, 2013 at 10:15 comment added user2713270 this is not duplicate... I really donot know about JavaScript.. and if it is there in JavaScript. some differences will be there.. right? so please give some understandings how about node.js
Aug 24, 2013 at 10:10 history edited user2713270 CC BY-SA 3.0
added 3 characters in body; edited tags
Aug 24, 2013 at 10:10 history edited Eric
edited tags
Aug 24, 2013 at 10:09 history asked user2713270 CC BY-SA 3.0
toggle format

AltStyle によって変換されたページ (->オリジナル) /