JavaScript中的函数文字是什么?
函数文字是定义未命名函数的表达式。您可以尝试运行以下代码以在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 = "Call Function">
</form>
</body>
</html>