89
rated 0 times
[
95]
[
6]
/ answers: 1 / hits: 78754
/ 12 Years ago, sat, march 24, 2012, 12:00:00
Can I dynamically call an object method having the method name as a string? I would imagine it like this:
var FooClass = function() {
this.smile = function() {};
}
var method = smile;
var foo = new FooClass();
// I want to run smile on the foo instance.
foo.{mysterious code}(); // being executed as foo.smile();
More From » oop