SSJS interpretation seems to be different from regular Javascript
-
11-06-2021 - |
سؤال
I found a difference between Lotus Domino SSJS iterpretation and regular Javascript.
Look at this snippet...
var mister = "mister in the hat".replace(" ", "-");
return mister
Regular Javascript does replave only once. The result is "mister-in the hat". SSJS does full replace. The result is "mister-in-the-hat".
Is there any documentation, in what way the SSJS is diferent from regular JS?
المحلول
I suspect Server-Side JavaScript will be influenced more by Java rather than JavaScript. This is because any SSJS written is just passed as a string to a Java method that parses the code at runtime. I know of ither differences to CSJS - parseInt, for example, defaults to base 10, not base 8 (JavaScript default).
The behaviour is documented in the Domino Designer help, under Lotus Domino Designer XPages Reference - Standard (JavaScript) - String - Replace. If in doubt, check out the Help. It's very good for these libraries, with plenty of examples as well as documentation.