我们如何使用函数文字来定义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>热门推荐
3 祝福语简短的微信
10 幼儿祝福语大全简短贺卡
11 感谢教官文案祝福语简短
12 鼠年同事祝福语简短创意
13 元旦祝福语 简短独特群发
14 妈咪跟我生日祝福语简短
15 给儿子新婚祝福语简短
16 伴娘祝福语长文案简短
17 恭喜高考完祝福语简短
18 生日祝福语送老公简短