标签云

微信群

扫码加入我们

WeChat QR Code


A 'use strict'; string before any statement of a function will put it in strict mode.

2018年10月23日42分35秒

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).

2018年10月23日42分35秒

GoloRoden: Is it a no-go? Chrome behaves exactly the same way as node here.

2018年10月23日42分35秒

Eric: Thanks, Chrome behaves exactly the same way as node here.. since V8 is the interpreter.. ;)

2018年10月23日42分35秒

Mohit Pandey: Fact is I referred stack overflow for learning node.js . I referred this link: stackoverflow.com/questions/2353818/…. So registered and asked this questions.. love the way people commented and answered so quickly... thanks to all.....

2018年10月23日42分35秒

Why is this answer downvoted without any comment?

2018年10月23日42分35秒

First of all, Chrome is not the only browser on the planet. Just that Node.js and Chrome use V8, does not mean neccessarily that it works the same in all browsers. Second, there is a difference in the way, files (aka modules) are loaded. Third, scripts for browsers get usually concatenated for production use, and that's where problems may arise when you just say that both are the same environments. They're not. V8 is not the only important thing when it comes to executing Node.js files.

2018年10月23日42分35秒

GabrielLlamas: Thanks. Golo Roden: Yes, if commented properly. we can give more better answers.

2018年10月23日42分35秒

AmolMKulkarni : "Module code is always strict mode code" - it is not exactly true for Node. If you will not use 'use strict' in node v.6.10.2 following code will not throw error: var obj = {}; Object.preventExtensions(obj); obj.a=1;

2018年10月23日42分35秒

This could be helpful research about default strict mode: imaginativethinking.ca/…

2018年10月23日42分35秒