javascript当中函数指针用法

12)函数指针

例 3.12.1

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>

    <script type="text/javascript">

        function sortNumber(a, b)
        {
            document.writeln(a + b);
        }
        function sortq(sortNumberqqq)
        {
            document.writeln("马克-to-win");
            sortNumberqqq(1, 2);
            return 6;
        }
        /* note that it will report error if we write the following statement as document.write("test "+sortq(sortNumberqixy));
       note that here sortNumber is a function pointer.
        下面这句话是先执行sortq(sortNumber),等返回值以后,再执行document.write("test "*/
        document.write("test " + sortq(sortNumber));


详见:http://www.mark-to-win.com/index.html?content=Javascript/jsUrl.html&chapter=Javascript/js1_web.html#functionPointer

猜你喜欢

转载自blog.csdn.net/mark_to_win/article/details/88615049
今日推荐