Permalink
Browse files

Defense against window.prototype

  • Loading branch information...
1 parent 40f3377 commit 43d7836c8ec9b31a02a31ae0c400bdae04d3650d @douglascrockford committed Oct 8, 2012
Showing with 4 additions and 6 deletions.
  1. +2 −3 json.js
  2. +2 −3 json2.js
View
5 json.js 100755 → 100644
@@ -1,6 +1,6 @@
/*
json.js
- 2011-08-30
+ 2012-10-08
Public Domain
@@ -196,8 +196,7 @@
// Create a JSON object only if one does not already exist. We create the
// methods in a closure to avoid creating global variables.
-var JSON;
-if (!JSON) {
+if (typeof JSON !== 'object') {
JSON = {};
}
View
@@ -1,6 +1,6 @@
/*
json2.js
- 2011-10-19
+ 2012-10-08
Public Domain.
@@ -159,8 +159,7 @@
// Create a JSON object only if one does not already exist. We create the
// methods in a closure to avoid creating global variables.
-var JSON;
-if (!JSON) {
+if (typeof JSON !== 'object') {
JSON = {};
}

0 comments on commit 43d7836

Please sign in to comment.