Problem with using arrow functions
Dear community, am having bit of an issue using arrow function defined in another file. Code snippet is below. Looking forward to any hints.
Test1.JS
-------------
const str = 'xyz';
const getStr = () => str;
Test2.JS
-------------
//USEUNIT Test1
function test() {
Log.Message(Test1.getStr());
}
I get an error at the statement where Test1.getStr() is called.
JavaScript runtime error.
TypeError: Test1.getStr is not a function
If I modify Test1.JS to the below lines, it then starts working.
const str = 'xyz';
getStr = () => str; //notice that I have removed const
Any idea what am missing? Did I hit a limitation in TestComplete? BTW, if the arrow function and the caller are in the same JS file, it works with no issues.
Best Regards,
Madhu
Same is mentioned in this post A const value does not work in other files | SmartBear Community