教学文库网 - 权威文档分享云平台
您的当前位置:首页 > 文库大全 > 资格考试 >

ECMAScript for XML Specification(Ecma-357)(4)

来源:网络收集 时间:2026-03-29
导读: 1. Let currentPrice be the result of calling the [[Get]] method of item with argument price The second convention for accessing normal properties is expressed using the following notation: - 5- 欧洲

1. Let currentPrice be the result of calling the [[Get]] method of item with argument "price"

The second convention for accessing normal properties is expressed using the following notation:

- 5-

欧洲计算机制造商协会(ECMA)标准文档

object [ propertyName ]

When used on the left hand side of an assignment operation, this property access convention is equivalent to calling the Object [[Put]] method with object as the this object, passing ToString(propertyName) and the value from the right hand side of the assignment operator as arguments. For example, the following algorithm fragment:

1. Let item[1] = item2

is equivalent to the following algorithm fragment:

1. Call the Object [[Put]] method with item as the this object and arguments ToString(1) and item2

When used in other contexts, this property access convention is equivalent to calling the Object [[Get]] method with object as the this object and argument ToString(propertyName). For example, the following algorithm fragment:

1. Let item2 = item[1]

is equivalent to the following algorithm fragment:

1. Let item2 be the result of calling the Object [[Get]] method with item as the this object and argument

ToString(1)

This is a convenient and familiar notation for specifying numeric property names used as array indices.

The convention for accessing internal property names, including those that refer to internal methods, is specified using the following notation:

object . [[ internalPropertyName ]]

When used on the left hand side of an assignment operation, this property access convention is equivalent to setting the value of the [[ internalPropertyName ]] of the specified object to the value from the right hand side of the assignment operator. For example, the following algorithm fragment:

1. Let x.[[Class]] = "element"

is equivalent to the following algorithm fragment:

1. Let the value of the [[Class]] property of x be "element"

When used in other contexts, this property access convention is equivalent to getting the value of the [[internalPropertyName]] property of object. For example, the following algorithm fragment:

1. Let class = x.[[Class]]

is equivalent to the following algorithm fragment:

1. Let class be the value of the [[Class]] property of x

7.1.3 Iteration

This specification extends the notation used for describing ECMAScript Edition 3 by defining two iteration conventions. These iteration conventions are used by this specification for expressing that a set of steps shall be taken once for each item in a collection or once for each integer in a specified range.

The first iteration convention is defined for expressing a sequence of steps that shall be taken once for each member of a collection. It is expressed using the following for each notation: For each item in collection steps

This for each notation is equivalent to performing the given steps repeatedly with the variable item bound to each member of collection. The value of collection is computed once prior to performing steps and does not change while performing steps. The order in which item is bound to members of collection is implementation dependent. The repetition ends after item has been bound to all the members of collection or when the algorithm exits via a return or a thrown exception. The steps may be specified on the same line following a comma or on the following lines using the indentation style described in section . For example,

- 6-

欧洲计算机制造商协会(ECMA)标准文档

1. Let total = 0 2. For each product in groceryList

a. If product.price > maxPrice, throw an exception b. Let total = total + product.price

In this example, steps 2.a and 2.b are repeated once for each member of the collection groceryList or until an exception is thrown in line 2.a. The variable product is bound to the value of a different member of groceryList before each repetition of these steps.

The second iteration convention defined by this specification is for expressing a sequence of steps that shall be repeated once for each integer in a specified range of integers. It is expressed using the following for notation: For variable = first to last steps

This for notation is equivalent to computing first and last, which will evaluate to integers i and j respectively, and performing the given steps repeatedly with the variable variable bound to each member of the sequence i, i+1 … j in numerical order. The values of first and last are computed once prior to performing steps and do not change while performing steps. The repetition ends after variable has been bound to each item of this sequence or when the algorithm exits via a return or a thrown exception. If i is greater than j, the steps are not performed. The steps may be specified on the same line following a comma or on the following lines using the indentation style described above. For example,

1. For i = 0 to priceList.length-1, call ToString(priceList[i])

In this example, ToString is called once for each item in priceList in sequential order.

A modified version of the for notation exists for iterating through a range of integers in reverse sequential order. It is expressed using the following notation: For variable = first downto last steps

The modified for notation works exactly as described above except the variable variable is bound to each member of the sequence i, i-1, .. j in reverse numerical order. If i is less than j, the steps are not performed.

7.1.4 Conditional Repetition

This specification extends the notation used in the ECMAScript Edition 3 specification by defining a convention for expressing conditional repetition of a set of steps. This conv …… 此处隐藏:5794字,全部文档内容请下载后查看。喜欢就下载吧 ……

ECMAScript for XML Specification(Ecma-357)(4).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.jiaowen.net/wenku/97867.html(转载请注明文章来源)
Copyright © 2020-2025 教文网 版权所有
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:78024566 邮箱:78024566@qq.com
苏ICP备19068818号-2
Top
× 游客快捷下载通道(下载后可以自由复制和排版)
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能出现无法下载或内容有问题,请联系客服协助您处理。
× 常见问题(客服时间:周一到周五 9:30-18:00)