1

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?

3
  • That's a nodeJS module. You might be able to get it to work if you use Browserify, but that won't work in the browser as it stands. Commented Mar 12, 2014 at 15:18
  • Your variable is in another castle. Search through the other files Commented Mar 12, 2014 at 15:18
  • @Andy I actually used Browserify and it still didn't work... Apparently browserify didn't change these statements. They are in the bundle just the same as they are in the Node.js code. Commented Mar 12, 2014 at 15:19

3 Answers 3

1

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

Sign up to request clarification or add additional context in comments.

1 Comment

1

Global variable came from the implementation of javascript in nodeJS

You can see it as Windows object for implementation of javascript in a web browser

Comments

0

The code you are looking at is designed to run in a Node.JS environment.

The GLOBAL variable is documented in the node manual.

It is a feature provided by the Node environment and not a core part of JavaScript.

1 Comment

That is not documented; Javascript is case-sensitive.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.