回调函数

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body>
	<script>
		function num1(a){
			num2(a, function(i){
				if(typeof a !== 'number') return;
				var value = i*a;
				console.log(value);
			})
		}
		function num2(temp_a, callback){
			num3(function(b){
				callback(b)
			})
		}
		function num3(callback){
			callback(3);
		}
		console.log(num1(10));
	</script>
	</body>
</html>

  回调函数主要看callback最终传值问题,只要看清楚是怎么一层一层的传值就ok了。

原文地址:https://www.cnblogs.com/viper-Demo/p/6019607.html