Javascript 字符串格式化及对象类型判断


//TODO 字符串格式值
String.prototype.formatValue = function(){

var args = arguments;

return this.replace(/{(\d+)}/g,function( item,index ){

return args[index];
});
};

 

(function( window ){

var Utils = {

//TODO 判断当前参数的类型
type : function( param ){

return param == null ? String( null ) : Object.prototype.toString.call( param ).toLowerCase().split(" ")[1].replace("]","") || "object";
}

};

window.Utils = Utils;

})( window );

posted @ 2015-11-07 00:24  Guang_Ming  阅读(178)  评论(0编辑  收藏  举报