javascript當中函數(shù)指針用法
例 3.12.1
馬克- to-win:馬克 java社區(qū):防盜版實名手機尾號: 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.
下面這句話是先執(zhí)行sortq(sortNumber),等返回值以后,再執(zhí)行document.write("test "*/
document.write("test " + sortq(sortNumber));
</script>
</HEAD>
<BODY>
</BODY>
</HTML>
輸出結(jié)果:
馬克-to-win 3 test 6