JavaScript 默认关键字
我正在使用一些现有的代码,但有一行我不明白。我只知道default可以用作swtich语句的一部分,但不知道它是否还有其他用途。该代码有效。它是 TurkIt 的一部分,用于通过 Amazon 的 MTurk 运行程序。
function getQuestion(numA, numB) {
default xml namespace = "http://mechanicalturk.amazonaws.com/AWSMechanicalTurkDataSchemas/2005-10-01/QuestionForm.xsd";
var q = <QuestionForm> ...
请参阅 xml namespace
语句之前的 default
。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
默认 xml 命名空间
是一个 ECMAScript for XML (E4X) 指令。E4X 是 ECMAScript 的扩展,它允许您将 XML 视为原始类型(这也是
var q =...
部分所发生的情况)。default xml namespace
指令设置(正如您所期望的)与指令相同作用域的默认 XML 命名空间。据我所知,Mozilla 的 SpiderMonkey(Firefox 和其他 Gecko 浏览器使用的引擎)和 Rhino 是唯一支持 E4X 的 JavaScript 引擎,但基于 ECMAScript 的 ActionScript 3 也可以。我假设 TurkIt 被设计为在 Rhino 上运行。
default xml namespace
is 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 namespace
directive 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.