首页 > 编程语言 > 详细

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

时间:2015-11-07 00:47:18      阅读:216      评论:0      收藏:0      [点我收藏+]


//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 );

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

原文:http://www.cnblogs.com/Ming2020/p/4944027.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!