I am trying to use Animal
object inside the World
object but both of them are in different files.
Animal.js :
function Animal(species, nature) {
// Public Fields
this.species = species;
this.nature = nature;
// Private Fields
var preys = new Array();
// GET Functions
..........
..........
// SET Functions
..........
..........
}
World.js :
function World() {
var animals = new Array();
var animal = new Animal("Wolf", "Carnivore"); //[1]
animals.push(new Animal("Wolf", "Carnivore")); //[2]
}
I am calling word class in a basic website which contains nothing but javaScript code which creates a new World
instance. Then in the browser, I press F12 and both in step 1 and step 2 I am getting an error.
Error ScreenShot : []
I think it can not find the animal class. I read a number of articles and also searched on the internet but I could not find(Maybe because of being new in JavaScript).
EDIT :
In other words, I am trying to import Animal.js
file into the World.js
file. Then I will import World.js
to Ecosystem.js
And here is the asp.net folder :
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="scripts/World.js"></script>
<script type="text/javascript">
world = new World();
world.getOmnivores();
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>