Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript: besides "use strict", which other "use" directives are there?

Besides use strict, which other use directives are there?

like image 314
fbas Avatar asked Aug 09 '11 16:08

fbas


1 Answers

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 stricter+types';
    • http://www.2ality.com/2015/02/soundscript.html
  • '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).

like image 69
GitaarLAB Avatar answered Oct 05 '22 20:10

GitaarLAB