Defense against window.prototype

This commit is contained in:
Douglas Crockford 2012-10-08 14:40:29 -07:00
parent 40f3377a63
commit 43d7836c8e
2 changed files with 4 additions and 6 deletions

5
json.js Executable file → Normal file
View file

@ -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 file

@ -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 = {};
}