I am a JavaScript newb but am familiar with the procedural/dynamic workings of Ruby. What is the simplest way to start executing code from a different JavaScript file? All I know how to do is execute code from one file.
Node.js uses what is called the Common.JS module pattern. A module exports an object, which is loaded by whatever required the module.
For instance, suppose I have a file called SomeClass.js:
exports = function SomeClass () {
this.func = function () {
console.log('func!');
}
}
Now in my main app.js:
var SomeClass = require('./SomeClass.js');
var someClass = new SomeClass();
someClass.func(); // outputs "func!" to console
You can read more about this in the official docs: http://nodejs.org/api/modules.html