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
// Based on an article by kyle simpson - youdontknowjs | |
// =================================================== | |
// | |
// String(x) | |
// | |
if ( String(0) !== "0") throw '' | |
if ( String(.0) !== "0") throw '' | |
if ( String(-0) !== "0") throw '' | |
if ( isNaN( String(NaN) ) === false) throw '' |
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
// | |
// see: http://underscorejs.org/ | |
// | |
load('http://underscorejs.org/underscore-min.js'); | |
sum = 0; | |
_.each([1, 2, 3],function(i) { sum+=i }); | |
if (sum !== 6) throw ''; |
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
// first cut. | |
// see: http://arasatasaygin.github.io/is.js/ | |
// | |
load('http://arasatasaygin.github.io/is.js/scripts/is.js'); | |
var getArguments = function() { | |
return arguments; | |
}; | |
var arguments = getArguments(); |
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
// make sure it doesn't count my own properties | |
(function () { | |
var results, currentWindow, | |
// create an iframe and append to body to load a clean window object | |
iframe = document.createElement('iframe'); | |
iframe.style.display = 'none'; | |
document.body.appendChild(iframe); | |
// get the current list of properties on window | |
currentWindow = Object.getOwnPropertyNames(window); | |
// filter the list against the properties that exist in the clean window |
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
// | |
// Showcase for Esprima. | |
// http://esprima.org | |
// | |
// This work is based on the following work | |
// https://github.com/marijnh/acorn/blob/master/test/tests.js | |
// | |
load('http://esprima.org/esprima.js'); |
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
// | |
// A basic function to check whether two values are equal, in the intuitive sense. | |
// | |
function equal(a, b) { | |
if (a !== null && a !== undefined && b !== null && b !== undefined) { | |
if (a.length !== b.length) return false; | |
if (a !== a.toString() && b !== b.toString()) { | |
for (var i in a) { if (!equal(a[i],b[i])) return false; } | |
for (var i in b) { if (!equal(a[i],b[i])) return false; } | |
} |
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
// | |
// javascript's math | |
// | |
var x = 0.1; | |
var y = 0.2; | |
if (x+y == 0.3) throw ''; | |
if (x+y != 0.30000000000000004) throw ''; |
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
// | |
// A falsy value is a value that translates to false when evaluated in a Boolean context. | |
// see: https://developer.mozilla.org/en-US/docs/Glossary/Falsy | |
// | |
if (false) throw ''; | |
if (null) throw ''; | |
if (undefined) throw ''; | |
if (0) throw ''; | |
if (NaN) throw ''; | |
if ('') throw ''; |
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
// | |
// see: papaparse.com | |
// use cases derived from https://raw.githubusercontent.com/mholt/PapaParse/master/tests/test-cases.js | |
// | |
load('http://papaparse.com/resources/js/papaparse.js'); | |
//One row | |
oj = Papa.parse("A,b,c"); | |
if (oj.data === null) throw ""; |
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
// | |
// numerals.js - a javascript library for formatting and manipulating numbers | |
// | |
// http://numeraljs.com/ | |
// https://github.com/adamwdraper/Numeral-js | |
// | |
// | |
// This work has been derived from | |
// https://github.com/adamwdraper/Numeral-js/blob/master/tests/numeral/format.js | |
// |
OlderNewer