Yes, you can utilize JavaScript outside the browser. Both for server-side scripting (similar to JSP or ASP). This can most notably be accomplished using Node.js (http://www.commonjs.org/) however there are other options available. Similarly you can create aps entirely outside of the webspace using the CommonJS API (http://www.commonjs.org/).
Check out the Wikipedia article about JavaScript (http://en.wikipedia.org/wiki/JavaScript#Server-side_JavaScript).