Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9bff15b

Browse files
committed
Merge pull request chuanxshi#8 from aborjinos/patch-1
Access to global object in ES3, ES5 and ES5-strict with partial eval.
2 parents d72614c + 4b2ff7c commit 9bff15b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

general-patterns/access-to-global-object.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
<body>
88
<script>
99
// access to the Global Object
10-
// no longer the case in ECMAScript 5 in strict mode
10+
// this should work in ES3, ES5 and ES5-strict.
1111
var global = (function () {
12-
return this;
12+
return this || (1,eval)('this');
1313
}());
1414

1515
// reference

0 commit comments

Comments
 (0)