JS全局变量是如何工作的?
JS全局变量是如何工作的?
-
<script> -
const one = 1; -
var two = 2; -
</script> -
<script> -
// All scripts share the same top-level scope: -
console.log(one); // 1 -
console.log(two); // 2 -
-
// Not all declarations create properties of the global object: -
console.log(window.one); // undefined -
console.log(window.two); // 2 -
</script>
本文来自博客园,作者:ukyo--碳水化合物,转载请注明原文链接:https://www.cnblogs.com/ukzq/p/11421852.html

浙公网安备 33010602011771号