34

ECMAScript 5 is in its final draft as I write this; It is due to include a strict mode which will prevent you from assigning to the global object, using eval, and other restrictions. (John Resig's Article is a good introduction.)

This magical sanity-saving mode is triggered by including the string "use strict" at the top of your file (or function.) However, in older environments, "use strict" is a no-op. If you add "use strict" and don't test it in a strict environment, you could be leaving a time-bomb of not-really-strict code that will break when it really hits a strict environment.

Which environments actually respect "use strict"?

Shog9
  • 156,901
  • 35
  • 231
  • 235
Sean McMillan
  • 10,058
  • 6
  • 55
  • 65
  • 2
    So, I found the tracking bug for Mozilla's implementation: https://bugzilla.mozilla.org/show_bug.cgi?id=482298 (That's for SpiderMonkey, I think.) – Sean McMillan Sep 15 '09 at 15:54
  • Here's the tracking bug for Rhino's ES5: https://bugzilla.mozilla.org/show_bug.cgi?id=489326 and the "Strict mode" bug for Rhino: https://bugzilla.mozilla.org/show_bug.cgi?id=517860 – Sean McMillan Oct 05 '09 at 15:51
  • Looks like this is as close to a tracking bug as we'll get for Webkit/JavaScriptCore: https://bugs.webkit.org/show_bug.cgi?id=10701 – Sean McMillan May 26 '10 at 19:10
  • More information on ES5 Support (including strict) in SpiderMonkey/Firefox: https://wiki.mozilla.org/JavaScript:SpiderMonkey:PathToFirefox4 – Sean McMillan Aug 10 '10 at 21:09
  • 1
    Code lands in Webkit: https://trac.webkit.org/changeset/69516 – Sean McMillan Oct 11 '10 at 23:08
  • Firefox and webkit are very close: https://twitpic.com/2xkurz/full (via kangax on twitter) – Sean McMillan Oct 14 '10 at 19:31
  • Looks like there's a tracking page on the ecma wiki as well: http://wiki.ecmascript.org/doku.php?id=es3.1:es3.1#track_status_of_es5_implementations_in_progress – Sean McMillan Oct 19 '10 at 21:06
  • Firefox 4 beta 7 has implemented strict mode and is working to some extend. – Raynos Nov 12 '10 at 14:15
  • Mozilla page on strict mode, with some implementation notes: https://developer.mozilla.org/en/JavaScript/Strict_mode – Sean McMillan Dec 11 '10 at 17:09
  • Chromium http://codereview.chromium.org/6144005/ and v8 http://code.google.com/p/v8/issues/detail?id=919 issue tracking pages. – Sean McMillan Apr 04 '11 at 17:35

4 Answers4

26

Update:

See my compatibility table.

Original response:

None as of now.

Raphael Speyer was working on Mozilla implementation for Rhino during this summer, and afaik, their implementation is pretty close to completion.

I know (based on info from ES-discuss list) that Microsoft is planning to include some of ES5 features into upcoming versions of IE and they might very well be working on strict mode implementation right now (as you probably know, IE8 already includes some of ES5 features, like Object.defineProperty).

There's also Google's Caja project which somewhat emulates behavior of strict mode in some of its variations (Valija, Cajita, etc).

Crockford also recently added this option to JSLint, but I'm not sure if it actually triggers any additional validations (as per ES5-strict rules).

kangax
  • 38,898
  • 13
  • 99
  • 135
  • Even worse, Speyer ran out of time and didn't implement strict mode, so even though Rhino will support most of the other ES5 features, it doesn't support strict mode. :-( – Sean McMillan Sep 15 '09 at 14:10
12

Now that it's actually released, Firefox 4 is the winner of "first browser to support ES5 Strict Mode." Now you can start using it, as long as you test in Firefox 4.


Safari 5.1+ and Chrome 13+ Also support strict mode.


The first One is in: Besen. Implemented in Delphi. I think it's stand-alone, but I'm not sure. But it does support strict mode.

Found via this compatibility table.


Jurassic claims to support ES5 Strict Mode.

Sean McMillan
  • 10,058
  • 6
  • 55
  • 65
9

ECMAscript 5 strict mode requires these versions for major browsers (or higher):

Chrome 13.0
Safari 5.1
Firefox 4.0
Internet Explorer 10.0
Opera 11.6

No, IE9 does not have strict support, it's new to version 10 or later.

whitneyland
  • 10,632
  • 9
  • 60
  • 68
1

Opera 11.60 already fully supports ECMAScript 5.1 and it's strict mode variation. See @kangax compatibility table.

marcio
  • 10,002
  • 11
  • 54
  • 83