I\'ve been trying to do javascript for sometime now, but i want it to be \"object-orientated\" so I\'m trying to create different javascript classes in different files and try t
Currently JavaScript is not clever enough to find your dependencies without help.
You need:
javascript test
Note:
If you want on-demand load of the dependencies then you can use AMD (Asynchronous Module Definition) with requirejs or something else.
Using AMD you can define something like:
define(['Job', 'person'], function (job, person) {
//Define the module value by returning a value.
return function () {};
});
The define method accepts two arguments: dependencies and function which defines the module. When all dependencies are loaded they are passed as arguments to the function where is the module definition.
One more thing to notice is that Person
and Job
are not classes. They are just functions (constructor functions) which produces objects based on rules in their definitions.