Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
348 views
in Technique[技术] by (71.8m points)

ecma262 - JavaScript: Can ECMAScript 5's Strict Mode ("use strict") be enabled using single quotes ('use strict')?

JavaScript doesn't care if your Strings are double-quoted "double" or single-quoted 'single'.

Every example of ECMAScript 5's strict mode has it enabled by "use strict" in double-quotes. Can I do the following (single-quotes):

alert(function(){
  'use strict';
  return !this;
}());

This will return true if Strict mode is enabled, and false if it is not.

question from:https://stackoverflow.com/questions/5214391/javascript-can-ecmascript-5s-strict-mode-use-strict-be-enabled-using-singl

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

For you, without using a browser that supports strict mode:

A Use Strict Directive is an ExpressionStatement in a Directive Prologue whose StringLiteral is either the exact character sequences "use strict" or 'use strict'. A Use Strict Directive may not contain an EscapeSequence or LineContinuation.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...