Inquisit 7 Introduces JavaScript!

Inquisit 7 has opened its doors to the JavaScript programming language. This means that Inquisit coders can now take advantage of a myriad of JavaScript programming capabilities, such as built-in JavaScript functions, advanced looping, the ability to write proper functions that can accept parameters (no more need to overwork expression elements!) and create (local) object and array variables. This is exciting news as it expands Inquisit's functionality enormously.

You can now use JavaScript code, although Inquisit 7 still supports IQScript in *.iqx files for backwards compatibility.

With the incorporation of JavaScript, some changes to the Inquisit core language were necessary to make:

File Extension: Inquisit 7 script files now use the file extension '.iqjs' (e.g. 'myscript.iqjs')

Curly Braces: Inquisit 7 now uses Curly Braces for trial, block and expt attributes. For example,' / onTrialBegin = {}' now uses {} instead of the [] brackets you may be used to.

Indexing: Indexing elements now starts at index = 0 instead of index = 1. For example, item.myStims.item(0) references the first item stored in item.myStims. Likewise list.myList.item(1) would refer to the second item in list.myList.

Case Sensitivity: Using upper and lower case spelling now matters in Inquisit. For example, if you declare 'values.currentStim' but reference it as 'values.currentstim' throughout the script, Inquisit 7 (in contrast to Inquisit 6) will not recognize it as the same variable.

Explicit Return Statements: All expressions as well as attributes '/ isValidResponse = {}', '/ isCorrectResponse = {}', '/ stop = {}', '/ skip = {}', as well as all branching attributes now require explicit return statements to execute the code.
For example

<expressions>
/ totalAmount = return (values.previousAmount + values.currentAmount)			
</expressions>
	

The good news is that Inquisit has also immensely improved its error messaging and will alert you to these changes very quickly in the majority of cases.

JavaScript Resources

The following general resources can be used to learn more about the JavaScript programming language:
  1. https://developer.mozilla.org/en-US/docs/Web/JavaScript
  2. https://www.w3schools.com/js/
  3. https://www.tutorialspoint.com/JavaScript/index.htm