js中的回调函数
程序员文章站
2022-05-29 21:24:48
...
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%
String path= request.getContextPath();
String basePath=request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<base href="<%=basePath%>"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>回调函数</title>
<script type="text/javascript" src="js/jquery-1.7.1.min.js"></script>
<script type="text/javascript">
//返回值是一个函数格式
function a(callBackFunction){
console.log("这是parsent函数a");
var m=1;
var n=3;
return callBackFunction(m,n);
}
function b(m,n){
console.log("这是回调函数b");
return m+n;
}
$(function(){
var result=a(b);
//输出结果是:4
console.log("result="+result);
var c=function(){
return 3*4;
};
console.log("输出的结果是:"+c());
});
</script>
</head>
<body>
</body>
</html>
pageEncoding="UTF-8"%>
<%
String path= request.getContextPath();
String basePath=request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<base href="<%=basePath%>"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>回调函数</title>
<script type="text/javascript" src="js/jquery-1.7.1.min.js"></script>
<script type="text/javascript">
//返回值是一个函数格式
function a(callBackFunction){
console.log("这是parsent函数a");
var m=1;
var n=3;
return callBackFunction(m,n);
}
function b(m,n){
console.log("这是回调函数b");
return m+n;
}
$(function(){
var result=a(b);
//输出结果是:4
console.log("result="+result);
var c=function(){
return 3*4;
};
console.log("输出的结果是:"+c());
});
</script>
</head>
<body>
</body>
</html>
上一篇: 批量生成url
下一篇: Vue怎样进行局部作用域 & 模块化