来自jQuery源代码:
jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " +
"mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
"change select submit keydown keypress keyup error contextmenu").split(" "), function( i, name ) {
// Handle event binding
jQuery.fn[ name ] = function( data, fn ) {
return arguments.length > 0 ?
this.on( name, null, data, fn ) :
this.trigger( name );
};
});
是否有理由从一串事件类型开始,然后将该字符串拆分为数组,而不是使用数组开头:['blur', 'focus', 'focusin', 'focusout', 'load',...]
?如果你要以字符串开头,为什么不使用单个字符串而不是连接三个字符串?