Forum Discussion

Novari-QA's avatar
Novari-QA
Frequent Contributor
7 years ago
Solved

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
    7 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");