Some common syntactical differences between Jscript and JavaScript are:
1: Referencing a Compound Question (e.g. a Multi type question or a Grid).
In Jscript we can reference the element of a compound question by using f(qid)[code] but this is not supported in JavaScript. Instead for JavaScript we use:
f(qid).item(code)
This syntax will work in both Jscript and JavaScript surveys so we recommend switching to the f(qid).item(code) syntax straightaway so there are less changes when switching to JavaScript surveys in the future.
2: Request.QueryString Indexer:
In Jscript we use Request.QueryString[param] to retrieve a parameter from the URL but in JavaScript we use
.item():
Request.QueryString.item(paramName)
3: Type Declaration
In Jscript variables can be declared with Type, eg:
var i : int = 0;
In JavaScript we don't declare Type so instead we would just declare variables with their name and initial value, ie:
var i = 0;
4: Creating a New Set Object
In Jscript we create a new Set object as:
var s = new Set();
but in JavaScript we simply use:
var s = set();
5: Piping Directly from Methods Returning an Array
For example:
.domainValues()
.domainLabels()
.categories()
.categoryLabels()
.values():
When piping directly from these methods, the output will need to be explicitly converted to a String. So for example:
In Jscript using ^f(qid).domainValues()^ would return a comma-separated list of answer codes presented to the respondent. But in JavaScript it would return System.Object[]
So, in JavaScript the piping must explicitly convert the Array to a String object like so:
^f(qid).domainValues().toString()^