In JavaScript™ we can access Java™ objects. This is very useful, because all the IBM TDI internal objects are Java objects.
However, there is a pitfall when some of the Java Objects have methods with names that are reserved words or operators in JavaScript. In these cases, the JavaScript interpreter tries to process the reserved word instead of calling the Java method.
Such an example can be found with the java.io.File class which has a delete method. delete is also a JavaScript operator, so the following call fails:
var myFile = java.io.File("file.txt"); myFile.delete();
Instead, we can do one of the following calls:
This exploits the fact that you can access the Java methods as array elements.
This works well, because the system library has a deleteFile method.