Hello I playing with javascript and I have the following situation
I have defined a point
class. I have defined an edge
class which depends on point
and a triangle
class which depends both on point
and edge
. How do I ensure that those classes are loaded correctly?
I use them as follows:
<script src="point.js" type="text/javascript"></script>
<script src="edge.js" type="text/javascript"></script>
<script src="triangle.js" type="text/javascript"></script>
<script src="utils.js" type="text/javascript"></script>
the utils.js
file are some generic utility functions that uses all of the above classes.
My problem is that I cannot tell the triangle
class for example, that the point
and edge
classes are defined. My code just assumes them to be defined somewhere or else it crashes burning down. Is there a simple #include
style mechanism for javascript?
For example I would like to just use the triangle
class which internally should somehow find about its dependencies and load them automagically