I use Windows primarily.
In every copy of Windows since Windows 95, there's a script host that allows you to run the Microsoft variant of Javascript, known as JScript, from the command line. Open a cmd.exe window, and type in filename.js and Windows will run the Jscript in that file.
JScript is Javascript, with some extensions for Windows. One extension: a JScript program can create a COM object; this means you could use a JScript program to automate Word, or to create a "Compressed folder" (a zip file), or to send a FAX, by interacting with the COM objects available on Windows for those purposes.
But, if you want to just focus on the Javascript language, how to structure programs and modules, or more pure algorithmic programming, then JScript running in Windows Script Host is a really good option, if you are on Windows.
For example, the JSLINT, JSHINT, and CSSHINT tools - all written in pure Javascript - are all available in versions that run on Windows Script Host, from the Windows command line. Using those versions, you could include a LINT check into a build script.
If you run a Javascript program on WSH, there is no HTML DOM. There is no window object, no document object. It's just Javascript.
Here's how I would structure your simple program for use on WSH:
(function(globalScope){
var test = "global";
function say(x){ WScript.Echo(x); }
function out() {
var test = "local";
return test;
}
say(out());
}(this));
Notice the use of WScript.Echo - that's a JScript-only extension. This is the output of the program:

For something a little more interesting, given this JS module:
(function(globalScope){
'use strict';
function say(x){ WScript.Echo(x); }
if (typeof Array.prototype.numericSort !== 'function') {
Array.prototype.numericSort = function() {
return this.sort(function(a,b){return a - b;});
};
}
var list = [17, 23, 2003, 39, 9172, 414, 3];
say("array: [" + list.toString() + "]");
var sortedList = list.numericSort();
say("sorted: [" + sortedList.toString() + "]");
}(this));
Running it on WSH looks like this:

You can see I've used prototypal inheritance of the Array object. All the usual JS language features are there. You can learn quite a bit, just doing programs that run from the command line.