By fbas


2011-08-09 16:47:16 8 Comments

Besides use strict, which other use directives are there?

3 comments

@GitaarLAB 2016-05-31 02:20:54

Some more examples that can be in the “directive prologue” (a section potentially usable by JavaScript engines):

  • 'use strict';
  • 'use asm';
    Mozilla's asm.js is a subset of the language, geared towards crunching numbers.
  • 'use stricter';
    Google's SoundScript. For fast OOP
    Has also some modes like:
  • 'use babel';
    Used in Atom.io. (Was previously: 'use 6to5';)

A tweet by Jeremy Ashkenas suggests some further use of + and - prefixes in the same 'use ...'; string ('use stricter +types -tco +jsx +asm +es2019-pre';), but that seems to contradict the spec (further clarified in kangax's answer and Bergi's answer).

@Jacob Johnson 2013-04-22 19:53:49

In case it's still of interest to anyone, I just ran across a "use asm" directive, for use with asm.js.

So it seems like there may be additional "use" options added over time.

@user113716 2011-08-09 17:04:18

Although it isn't a declarative like "use strict";, the next version of ECMAScript (codenamed Harmony) will apparently have an opt-in capability you can use in the <script> tag.

From this article:

  • opt-in via MIME type in script tag: <script type="application/javascript;version=next"> (where “next” is a placeholder for something that has still to be determined)

The article is an overview of this presentation by David Herman, which is very much worth watching.

@fbas 2011-08-09 17:23:12

Thanks, watching it now.

@gcampbell 2016-06-06 20:15:49

Just a note from the future, this never happened after all.

Related Questions

Sponsored Content

93 Answered Questions

[SOLVED] How do I make the first letter of a string uppercase in JavaScript?

43 Answered Questions

[SOLVED] How do I remove a property from a JavaScript object?

96 Answered Questions

[SOLVED] How can I remove a specific item from an array?

  • 2011-04-23 22:17:18
  • Walker
  • 6967585 View
  • 8524 Score
  • 96 Answer
  • Tags:   javascript arrays

61 Answered Questions

[SOLVED] How do I include a JavaScript file in another JavaScript file?

28 Answered Questions

[SOLVED] What does "use strict" do in JavaScript, and what is the reasoning behind it?

86 Answered Questions

[SOLVED] How do JavaScript closures work?

39 Answered Questions

[SOLVED] var functionName = function() {} vs function functionName() {}

3 Answered Questions

54 Answered Questions

Sponsored Content