闭包的基本用法

28 阅读1分钟
<script>
 var num=10;
function fn(){
	var num=20
	function fun(){
	console.log(num) //输出结果为:20
	}
	fun()
}
fn()

</script>