zoukankan      html  css  js  c++  java
  • 常用扩展-笔记

    // public
    /*
    *  格式化 
    */
    String.prototype.format = function () {
        var args = arguments;
        return this.replace(/{(d+?)}/g, function (g0, g1) {
            return args[+g1];
        });
    };
    
    /*
    * Array.prototype.forEach
    */
    Array.prototype.forEach = Array.prototype.forEach || function (callback) {
        callback = callback || function () { };
        for (var i = 0, len = this.length; i < len; i++) {
            callback.call(this[i], this[i], i);
        }
    };
    
    /*
    * Date.prototype.format
    */
    Date.prototype.format = function (format) {
        var dict = {
            "y+": this.getFullYear(),
            "M+": this.getMonth() + 1,
            "d+": this.getDate(),
            "H+": this.getHours(),
            "h+": this.getHours() - 12,
            "m+": this.getMinutes(),
            "s+": this.getSeconds()
        };
        for (var k in dict) {
            var reg = new RegExp(k, "g");
            format = format.replace(reg, function (g0) {
                return ("000000" + dict[k]).slice(-g0.length);
            });
        }
        return format;
    }
    
    //public end
    
    // module
    $(function () {
        module.inits.forEach(function (item, index) {   //所有模块初始化
            $.type(item) == "function" && item();
        });
    });
    
    var module = (function (my) {  //template
        my.inits = my.inits || [];
        
        return my;
    })(module || {});
    
    
  • 相关阅读:
    TCP同步与异步
    C#委托与事件
    线程
    C# 多人聊天程序
    vs启动错误
    记住我的痛苦
    C#命名空间与类名的冲突
    C#调试类
    linux ifconfig命令参数及用法详解linux查看配置网卡命令
    B/S架构
  • 原文地址:https://www.cnblogs.com/lianmin/p/5403996.html
Copyright © 2011-2022 走看看