Background
I am creating a javascript based application that works differently on mobile and desktop devices. However, with the exception of DOM manipulation, most of the codes are distributed between both platforms, so I structured all the files, such as: * foo.core.js * foo.mobile.js * foo.web.js
And hope to use object-oriented methods to write cleaner code.
Problem:
I have two JavaScript files, with classes
File 1:
function ClassA()
{}
ClassA.prototype.foo = function(){};
GreatGrandChildA.prototype = new GrandChildA();
function GreatGrandChildA ()
{}
File 2:
ChildA.prototype = new ClassA();
function ChildA () // ChildA inherits ClassA
{}
GrandChildA.prototype = new ChildA()
function GrandChildA () // GrandChildA inherits ClassA
{}
Typically, in a language like C ++, I would redirect the declaration GrandChildAdirectly to file 1. I would like to know how to do this in Javascript
Edit:
If I create a single file containing all four classes - in the same order in which they are loaded, the example works exactly as expected:
http://jsfiddle.net/k2XKL/