Skip to content

Commit

Permalink
Defense against window.prototype
Browse files Browse the repository at this point in the history
  • Loading branch information
douglascrockford committed Oct 8, 2012
1 parent 40f3377 commit 43d7836
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
5 changes: 2 additions & 3 deletions json.js
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
json.js
2011-08-30
2012-10-08
Public Domain
Expand Down Expand Up @@ -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 = {};
}

Expand Down
5 changes: 2 additions & 3 deletions json2.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
json2.js
2011-10-19
2012-10-08
Public Domain.
Expand Down Expand Up @@ -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 = {};
}

Expand Down

0 comments on commit 43d7836

Please sign in to comment.