为什么这么写
jQuery.each( "Boolean Number String Function Array Date RegExp Object Error Symbol".split( " " ),//为什么这么写
function( _i, name ) {
class2type[ "[object " + name + "]" ] = name.toLowerCase();
} );
而不是这么写
jQuery.each(['Number','Boolean','String','BigInt','Symbol','Null','Undefined',
'Object','Function','Array','Date','RegExp','Error'],function(index,item){
class2type["[object "+item+"]"]=item.toLowerCase();
});
多了一步split不自找麻烦吗,有啥用
没有特别的含义吧,就是个人编码习惯问题。coding的时候少输入些字符,并且
多了一步split
并不会对性能造成影响,JS执行是很快的。