Skip to content

Instantly share code, notes, and snippets.

@silianlinyi
Last active December 24, 2015 11:49
Show Gist options
  • Save silianlinyi/6793676 to your computer and use it in GitHub Desktop.
Save silianlinyi/6793676 to your computer and use it in GitHub Desktop.
在严格模式中,调用的函数(不是方法)中的一个this值是undefined。(在非严格模式中,调用的函数中的this值总是全局对象)。可以利用这种特性来 判断JavaScript实现是否支持严格模式。
var hasStrictMode = (function() {
"use strict";
return this === undefined;
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment