<!DOCTYPE html><html lang="en">
<head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta http-equiv="X-UA-Compatible" content="ie=edge"><title></title></head>
<body>
</body>
<script>var name = '张三';(function () {if (typeof name == 'undefined') {var name = '李四';console.log(name);} else {console.log('hello' + name);}})()</script></html> 主要的疑虑就是为什么取不到外部的值,以及这个函数前后两个括号各代表的是什么意思?这样会形成闭包吗? 劳烦哪位大佬给我解答,谢谢了~~
慕工程0101907
相关分类