A "hash table" is simply a more convenient way of saying "regular Javascript object." What an instructor means to “describe its definition” is another way of saying “a function that acts as a constructor for a class”.
Ultimately, what does it mean in the statement you mentioned:
each redefined entity definition will update the hash table with a pointer to the class definition
:
- All "subclasses" of Entity will register their design function in one common hash file / object, using the key, which is the value
type. - This allows you to get a constructor function (in other words, an
newon call function that will return an instance of this object) for any type by referring to gGameEngine.factory[type].
, , , , gGameEngine.factory , , .
, , JSON, , , - :
var typeConstructor = gGameEngine.factory(tileSpec.type),
instance;
if (typeConstructor) {
instance = new(typeConstructor)(tileSpec );
}
, 1 , .
?