javascript当中函数指针用法
例 3.12.1
马克- to-win:马克 java社区:防盗版实名手机尾号: 73203。
<!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));
</script>
</HEAD>
<BODY>
</BODY>
</HTML>
输出结果:
马克-to-win 3 test 6