Suppose you use the following structure:
var Args = new Object();
Args.Age = '10';
Args.Weight = '10';
Args.GetAge = function() {
return 'I am ' + Age + ' years old';
}
Args.GetWeight = function() {
return 'I weigh ' + Weight + ' pounds';
}
This works great. But is it possible to use a generic type, so you do not need to create a function for each variable? For example, something like the following:
Args.GetValue = function(i) {
return this.i;
}
This does not work, but I do not even know if this is possible. Does anyone know the answer to this riddle?
source
share