I’m using some existing code and there is this line I don’t understand. I only know that default can be used as part of a swtich statement, but didn’t know if there is some other use for it. The code works. It’s part of TurkIt which is used for running programs through Amazon’s MTurk.
function getQuestion(numA, numB) {
default xml namespace = "http://mechanicalturk.amazonaws.com/AWSMechanicalTurkDataSchemas/2005-10-01/QuestionForm.xsd";
var q = <QuestionForm> ...
See the default before the xml namespace statement.
default xml namespaceis an ECMAScript for XML (E4X) directive.E4X is an extension to ECMAScript that lets you treat XML like a primitive type (that’s also what’s going on with the
var q = <QuestionForm> ...part). Thedefault xml namespacedirective sets (As you might expect) the default XML namespace for the same scope as the directive.Mozilla’s SpiderMonkey (the engine used by Firefox and other Gecko browsers) and Rhino are the only JavaScript engines I know of that support E4X, but the ECMAScript-based ActionScript 3 also does. I assume TurkIt is designed to run on Rhino.