This file contains 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 obj = { foo: function () { return "bar"; } }; | |
var jsonString = JSON.stringify(obj, function (key, value) { | |
if (typeof value == 'function') { | |
return value(); | |
} | |
return value; | |
}); | |
// Firefox <= 3.6, produces invalid JSON: '{"foo":}' |
This file contains 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
/** | |
* This library defines a new style ES objects | |
* which support delegation based mixins. A mixin | |
* chain is stored in the internal [[Mixin]] property. | |
* | |
* Used features: Harmony (ES6) proxies. | |
* | |
* Tested in FF4 beta. | |
* | |
* @author Dmitry A. Soshnikov <[email protected]> |
This file contains 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
if (typeof Array.isArray != 'function') { | |
Array.isArray = (function () { | |
var toString = Object.prototype.toString; | |
return function (obj) { | |
return toString.call(obj) == '[object Array]'; | |
}; | |
})(); | |
} |
This file contains 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
// WebKit strict mode bugs | |
// Eval code should be "strict eval code" if the call to eval is a direct call (15.1.2.1.1) to | |
// the eval function that is contained in strict mode code: | |
(function () { | |
"use strict"; | |
return eval('(function() { return !this; })()'); | |
})(); | |
This file contains 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
Object.getPropertyNames || | |
Object.defineProperty(Object, "getPropertyNames", { | |
value: function(obj) { | |
var propertyNames = []; | |
do { | |
propertyNames.push.apply(propertyNames, Object.getOwnPropertyNames(obj)); | |
obj = Object.getPrototypeOf(obj); | |
} while (obj); | |
// get unique property names | |
obj = {}; |
This file contains 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 sb = { | |
Array: function() { | |
var result = Array.apply(null, arguments); | |
result.__proto__ = sb.Array.prototype; | |
return result; | |
} | |
}; | |
sb.Array.prototype = []; | |
sb.Array.prototype.last = function () { return this[this.length -1]; }; |
This file contains 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
/* | |
* List of ES3 Incompatibilities introduced by ES5. | |
* | |
*/ | |
/* | |
* From Annex E: | |
*/ |
This file contains 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
function isStrictFunction(fn) { | |
if (typeof fn != 'function') throw "Not a function"; | |
try { | |
fn.caller, fn.arguments; | |
return false; | |
} catch (e) { | |
return e instanceof TypeError; | |
} | |
} |
This file contains 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
if (typeof Function.prototype.bind != 'function') { | |
Function.prototype.bind = (function () { | |
var slice = Array.prototype.slice; | |
return function (thisArg) { | |
var target = this, boundArgs = slice.call(arguments, 1); | |
if (typeof target != 'function') throw new TypeError(); | |
function bound() { | |
var args = boundArgs.concat(slice.call(arguments)); |
This file contains 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
/* V8 Engine internals using built-ins | |
* | |
* Bug report: | |
* http://code.google.com/p/v8/issues/detail?id=1625 | |
* Bug on code: | |
* http://code.google.com/p/v8/source/browse/trunk/src/v8natives.js?r=8733#1026 | |
* http://www.google.com/codesearch#W9JxUuHYyMg/trunk/src/v8natives.js&l=1026,1029 | |
*/ | |
var _push = Array.prototype.push; |