Javascript中的GLOBAL变量是什么? [英] What is the GLOBAL variable in Javascript?

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

问题描述

此代码:
https://github.com/bjornharrtell /jsts/blob/master/index.js



引用一个名为GLOBAL的变量。


$ b

ReferenceError:GLOBAL未定义
$ b
当我在浏览器中执行此操作时,出现错误消息: $ b

这个GLOBAL来自哪里,为什么没有定义?

解决方案

在Node.js中, code> GLOBAL 是全局对象的别名(通常称为 global )。

在浏览器中,它不存在。



< Browserify会识别全局别名,并将注入对窗口的引用,但不会识别 GLOBAL



它已更改为全局 四年前


This code: https://github.com/bjornharrtell/jsts/blob/master/index.js

refers to a variable named "GLOBAL".

When I run this in a browser, I get an error message:

"ReferenceError: GLOBAL is not defined"

Where does this GLOBAL come from, and why is it not defined?

解决方案

In Node.js, GLOBAL is an alias to the global object (more commonly referred to as global).
In browsers, it doesn't exist.

Browserify recognizes the global alias, and will inject a reference to window, but does not recognize GLOBAL.

It was changed to global four years ago

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

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