I understand that JavaScript code is usually run using the browser, but how do I do that without an internet connection? I'm on a Mac and have installed NodeJS, but I'm not sure what commands I need to use, or what else I need to download to be able to run my JavaScript code in Chrome or Safari.
All modern browsers (including IE) will execute JavaScript - on and offline. But if you have Ajax calls or other requests fetching data from outside your local environment, you of course will run into problems.
To just run JavaScript in your browser just create a file like test.html and inside of it do something like this.
<script type="text/javascript">
alert('Hello world!');
</script>
Then open test.html in your browser. A popup should appear. You can put any JavaScript you want in between the script tags.
Just hit Command - Option - J
and you can use the javascript console on chrome don't need internet
You just need a browser. Check here to see if javascript is enabled in your browser. If not, in the same link I gave you, instructions to activate it.
Hope it's useful!
You might be confusing the distinction between Javascript (the language) and Node.js (the server-side runtime environment).¹
Node.js reads your Javascript code and designed to work on a network, but learning to use it would by no means require an internet connection.
If you have written, for example, a "hello world!" program in Javascript for Node.js, you would run it not with the browser but as follows:
node hello.js
Just like you would run a Python or Perl script, if that helps.
¹If you actually are still confused about what the difference between JS and Node, there is an answer here on SO that seems to do a good job of making it clear. It even covers some other uses of Javascript. What is the differences between Node JS, Ext JS, AngularJS?
Node.js
Remember how I told you that JavaScript ran in the browser, but I mentioned that there was one big exception to that? Node.js is that exception. It’s a command-line tool that runs JavaScript on a machine without needing to run in a browser. It does this by using a version of Chrome’s V8 Engine, which is the JavaScript engine that runs inside Google Chrome. ...