Мне определенно начинает нравиться IE10

window.matchMedia(''); // Error: "Invalid argument."

window.matchMedia('42'); // [object MediaQueryList]​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​

Гммм...

​// Так, я всегда думал:
events.on(document, 'click', function (evt){
    var node = evt.target;
    do {
        if( node.nodeType == 1 ){ // first step
            var href = node.href;
            if( /^http/i.test(href) ){ // ok, it's link
                if( node.tagName == 'IMG' ){
                    // IE: Hello, RubaXa!
                    // me: FFFFFUUUUUUUUuuuu!11
                }
            }
        }
    } while( node = node.parentNode );
});​​​​​​​​

    
// КАК, ПОЧЕМУ?
// Лучше запишу!
var img = new Image;
img.src = 'http://.../fuck.yeah';
if( img.href == 'http://.../fuck.yeah' ){
    // Ха-ха-ха!
}

// Ну, Ок, а если так
img.href = 'try.again';
img.href == 'http://.../fuck.yeah'; // true!!1

// Good night!

jsPerf.com

​// Прежде, чем оптимизировать какой-то кусок, поищите его тут:
http://jsperf.com/search?q=trim​​​​​​​​​​​​​

IE10 & FileAPI

​// Если  вы не знали, то IE10 поддерживает HTML5/FileAPI:
var reader = new File​Reader;
reader.readAsBinaryString(file); // error: Object doesn't support method or property "readAsBinaryString"


​// Но, выход есть!
var reader = new FileReader;
reader.onload = function (evt){
    var base64 = evt.result.replace(/^data:[^,]+,/, '');
    var binaryString = window.atob(base64); // bingo!
};
reader.readAsDataURL(file); 
​

Fastest html escape

// http://jsperf.com/htmlescape-vs-goog-string-htmlescape
// Если вам нужна самая быстрая функция htmlEspcae, то:

// (1) Просто и быстро
var htmlEscape = (function (){
    var _rhtml = /[&<>\"]/g,
        _map = { '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quote;' },
        _replace = function (c){ return _map[c]; }
    ;

    return function(str) {
        if( typeof str === "string" ){
                if( _rhtml.test(str) ){
                        return str.replace(_rhtml, _replace);
                }
        }
        return str;
    }
})();


// (2) goog.string.htmlEscape -- быстро и очень быстро в Chrome/Node/V8
// http://closure-library.googlecode.com/svn/docs/closure_goog_string_string.js.html
var googStringHtmlEscape = (function (){
    var _ramp = /&/g,
        _rlt = /,
        _rgt = />/g,
        _rquote = /\"/g,
        _rhtml = /[&<>\"]/
   ;

    return function (str){
        // quick test helps in the case when there are no chars to replace, in
        // worst case this makes barely a difference to the time taken
        if( typeof str !== 'string' || !_rhtml.test(str) ) return str;

        // str.indexOf is faster than regex.test in this case
        if( str.indexOf('&') != -1 )  str = str.replace(_ramp, '&amp;');
        if( str.indexOf('<') != -1 )  str = str.replace(_rlt, '&lt;');
        if( str.indexOf('>') != -1 )  str = str.replace(_rgt, '&gt;');
        if( str.indexOf('"') != -1 )  str = str.replace(_rquote, '&quote;');

        return str;
    }
})();​