JavaScript回调函数的理解

这里是个人对回调函数的一段理解

<!DOCTYPE html>
<html>
<head>
	<title>回调函数</title>
</head>
<script type="text/javascript">
	
	function testfun(){
		alert("hello");
	}
	//i = testfun();//会执行
	//i = testfun; // 将首地址给了i
	//i();         //同样会执行
	//这样其实就可以看到testfun 其实就是函数的首地址 ()的作用是执行那段地址的内容

/*(function name(){
	alert("myname is sun");
})();

function name(){
	alert("myname is sun");  //这个就是返回一个地址
}   */

(function name(){
	alert("myname is sun"); //这个就是返回一个地址的一个整体
})

(function name(){
	alert("myname is sun");//这个就是返回一个地址进行执行
})();

</script>
<body>

</body>
</html>

  

原文地址:https://www.cnblogs.com/sunxun/p/4438318.html