Javascript default keyword

I am using some existing code and I do not understand this line. I only know that the default value can be used as part of the swtich statement, but does not know if there is any other use for this. The code is working. This is the part of TurkIt that is used to run programs through Amazon MTurk.

function getQuestion(numA, numB) { default xml namespace = "http://mechanicalturk.amazonaws.com/AWSMechanicalTurkDataSchemas/2005-10-01/QuestionForm.xsd"; var q = <QuestionForm> ... 

See default before xml namespace statement.

+7
source share
1 answer

default xml namespace is an ECMAScript directive for XML (E4X) .

E4X is an extension for ECMAScript that allows you to consider XML as a primitive type (which also happens with the var q = <QuestionForm> ... ). The default xml namespace directive default xml namespace sets (as one would expect) the default XML namespace for the same scope as the directive.

Mozilla SpiderMonkey (the engine used by Firefox and other Gecko browsers) and Rhino are the only JavaScript engines that I know about this E4X support, but ECMAScript-based Actiona 3 also does . I assume TurkIt is designed to work on Rhino.

+14
source

All Articles