Last active
September 16, 2016 10:08
-
-
Save a7madgamal/22444e35531aa00b7e36932da8bb1001 to your computer and use it in GitHub Desktop.
Douglas crockford's js library coding style (not usable, learning purposes only)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var ADSAFE; | |
ADSAFE = (function () { | |
"use strict"; | |
function error(message) { | |
ADSAFE.log("ADsafe error: " + (message || "ADsafe violation.")); | |
} | |
return { | |
get: function (object, name) { | |
reject_global(object); | |
if (!reject_property(object, name)) { | |
return object[name]; | |
} | |
error(); | |
}, | |
// ADSAFE.isArray returns true if the operand is an array. | |
isArray: Array.isArray || function (value) { | |
return Object.prototype.toString.apply(value) === "[object Array]"; | |
}, | |
log: function log(s) { | |
if (window.console) { | |
console.log(s); | |
} else if (typeof Debug === "object") { | |
Debug.writeln(s); /* IE */ | |
} else { | |
opera.postError(s); /* Opera */ | |
} | |
}, | |
// ADSAFE._intercept allows the page to register a function that will see the widget's capabilities. | |
_intercept: function (f) { | |
interceptors.push(f); | |
} | |
}; | |
}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment