什么是javascript中的文件范围 [英] What is file scope in javascript

查看:36
本文介绍了什么是javascript中的文件范围的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

javascript 文件范围内声明的变量是什么?
考虑到一个应用程序中使用了多个文件,是否有任何文件范围.

What is variable declared within file scope in javascript?
Is there anything file scope, considering multiple files are used in an app.

推荐答案

ES6 模块形成了自己的文件作用域(就像文件的全部内容都被包裹在一个函数中一样).

ES6 modules form their own file scope (as if the entire contents of the file were wrapped in a function).

模块中声明的变量完全无法从模块外部访问(除非它们被exported).

Variables declared in a module are completely inaccessible from outside that module (unless they're exported).

这篇关于什么是javascript中的文件范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆