Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

Why is strict mode NOT the default behaviour?

I just keep asking myself why... It makes no sense for a developer tool to fail silently or to allow (not) defining variables in the global scope like that. It makes no sense at all.

BTW, is there a way to enable strict mode by default without "decorating! the JS code?

1 Answer

Essentially because if the teams in charge of browser development did make 'use strict' default, they'd be breaking a lot of sloppy code on the internet, inherently hurting their browser's compatibility. While it being default might disincentive "improper" coding, it'd also be greatly hurting any site that has "improper" code but doesn't have an active developer maintaining it.

I got that far but it seems like ECMA is encouraging crappy code instead. What I meant is that 'use strict' should be default and another istruction could be applied to allow weaker checks on code. Moreover they could just put a warning on non-strictly compliant code instead of failing silently which is useless in any case.