Instance
1. In programming, an instance is one occurrence of a class or object. For example, a program may have a class/object named Animal, but there could be many instances of Animal, such as lion, cat, and dog. An example using JavaScript is shown below. The Animal object is created and then three instances of the Animal object are created.
function Animal(numlegs, mysound) {
this.legs = numlegs;
this.sound = mysound;
}
var lion = new Animal(4, "roar");
var cat
= new Animal(4, "meow");
var dog = new Animal(4, "bark");
The Animal object allows for the number of legs and the sound of the animal to be set by each instance of the object that is created. In this case, all three instances (lion, cat, and dog) have the same number of legs but make different sounds. This allows for items that have a similar structure or perform similar functions to reuse code from the class/object, rather than needing to duplicate much of the code that would be in the class/object each time a new item is needed.
2. When referring to online games an instance is a location created for a single player or group or raid of players. This allows players to go to the same location, but not have to contend with other players who may also want to go to the same location and fight the same creatures.
Also see: Class, Game definitions, Object, Programming definition, Subroutine, Zone
