Forum Discussion

lherry's avatar
lherry
Contributor
2 years ago

Javascript private class features

Hello everyone,

I've been working for some time on TC in JavaScript and I've noticed that the language is more permissive than the documentation indicates, namely that it supports some native JS functions.

As I currently have classes, I would need to create private methods/properties.

As JS in its latest versions seems to be able to handle these functions (by adding a '#' in front of properties and methods), I tried on TC's IDE and found that the text is italicized, but this brings up a syntax error.

It seems that TC's javascript engine is based on an enhanced ECMA-262 version of SmartBear's proprietary layer. If this is the case, one might assume that the native JS version will perhaps be updated to a newer version in the near future?

Do you know if I'm right or not?
This would allow us to benefit from the latest language features (including private element management), which would be a real plus.

If not, would you have any ideas or suggestions for obtaining an almost similar result, other than making functions local to the script and not exported, allowing access to the local class?

Thanks in advance for your insights and help,
Loïc

  • Thank you rraghvani for your reply,

     

    I had read the page but had not noted the title on "Unsupported Features".

    As the page is formulated, I had not assimilated that one could take again all the functionality of the engine V8 version 5.8 except the information mentioned in the page.

     

    Well... Apart from the solution of creating functions or variables specific to the script containing the exported class, I can't see any other way of doing the equivalent of private methods or properties.

     

    If you have any other ideas, I'm not against it, so I'll leave the subject open for a while.

     

    Thanks in any case,
    Have a nice day!