我们如何使用函数文字来定义JavaScript中的函数?
JavaScript1.2引入了函数文字的概念,这是定义函数的另一种新方法。函数文字是定义未命名函数的表达式。
示例
您可以尝试以下示例在JavaScript中实现函数文字
<html>
<head>
<script>
<!--
var func = function(x,y){ return x*y };
function secondFunction(){
var result;
result = func(10,20);
document.write ( result );
}
//-->
</script>
</head>
<body>
<p>Click the following button to call the function</p>
<form>
<input type="button" onclick="secondFunction()" value="通话功能">
</form>
<p>Use different parameters inside the function and then try...</p>
</body>
</html>热门推荐
10 对患者生日祝福语简短
11 结婚祝福语简短装备
12 周岁祝福语学生文案简短
13 订婚领证祝福语简短精辟
14 导师获奖祝福语大全简短
15 新婚购房祝福语简短精辟
16 牛年祝福语简短的爱人
17 送芒果的祝福语简短
18 送给学长毕业祝福语简短