zoukankan      html  css  js  c++  java
  • 以前写的带参数的window.setTimeout(参数可为对象)

        以前写的,好不容易翻出来,还是写在这里,方便以后查询使用

    <script language="javascript">
    /*
        功能:修改 window.setTimeout,使之可以传递参数和对象参数
        使用方法: setTimeout(回调函数,时间,参数1,,参数n)
    */

    var __sto = setTimeout;
    window.setTimeout 
    = function(callback,timeout,param)
    {
        
    var args = Array.prototype.slice.call(arguments,2);
        
    var _cb = function()
        
    {
            callback.apply(
    null,args);
        }

        
        __sto(_cb,timeout);
    }


    ///测试代码

    function aaaa(a)
    {
        alert(a);
    }


    function aaaaa(a,b,c)
    {
        alert(a 
    + b + c);
    }



    var a = new Object();
    window.setTimeout(aaaa,
    1000,a);
    window.setTimeout(aaaaa,
    2000,a,6,7);
    </script>
  • 相关阅读:
    CF1270H
    CF1305G
    LeetCode-Sqrt(x)
    LeetCode-Plus One
    LeetCode-Integer to Roman
    LeetCode-Roman to Integer
    LeetCode-String to Integer (atoi)
    LeetCode-Reverse Integer
    C++
    LeetCode-Gray Code
  • 原文地址:https://www.cnblogs.com/evlon/p/743668.html
Copyright © 2011-2022 走看看