Skip to content

Instantly share code, notes, and snippets.

@zackd
zackd / test_number-expected.html
Created January 31, 2011 13:22
test proves IE array.sort unreliable
<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" >
</head>
<body>
<!-- source: http://www.zachleat.com/web/2010/02/24/array-sort/ -->
<!-- The Fix: Don’t reuse the argument variables inside of an Array sort function:
/* Changing the above example
@zackd
zackd / yui-trim.js
Created November 30, 2011 18:20
// YUI trim - for browsers with no native String.trim() e.g. IE < 9
// YUI trim - for browsers with no native String.trim() e.g. IE < 9
if (!String.prototype.trim) {
String.prototype.trim = function () {
try {
return this.replace(/^\s+|\s+$/g, "");
} catch(e) {
return this;
}
};
}