Ruby has a .method()
call where you can dynamically cal a method from an object. So if @object has @object.foo() and @object.bar() methods you could call @object.method(‘foo’).call
etc.
In JavaScript let’s say you have two functions defined the same foo() {}
and bar() {}
and I have a variable set like var type = ‘foo’
. Can you somehow call those functions dynamically from that variable?
Still learning JS so this may be a trivial question but I can’t seem find a quick answer.