I really have no idea how Javascript works. I am used to OOP languages. I have two javascript files, and I want to make a person object. I'm running Main.js as a node file.
Main.js
var p = require('./Person.js')
var person = new Person();
Person.js
exports = function Person ()
{
console.log("hello")
}
I've tried many different things, but it always says Person is not defined.
node Main
ReferenceError: Person is not defined.
Personcode's exports as the value of variablep, so it should bevar person = new p();Person.jsreally look exactly like what you've posted here?module.exports = ...not justexports. (I think.)