Forum Discussion

Novari-QA's avatar
Novari-QA
Frequent Contributor
8 years ago

Call function from string value JavaScript

I was hoping that TestComplete offered a method in which we can dynamically call specific functions based off of a string variable.   For example: This is how I would do it in C#. Unfortunately I a...
  • HKosova's avatar
    8 years ago

    There are a few ways.

     

    1) Square bracket notation:

    var method = "Message";
    Log[method]("test");

    2) $call:

    Log.$call("Message", "test");

    3) aqObject.CallMethod:

    aqObject.CallMethod(Log, "Message", "test");