1、 Reference numberISO/IEC 16262:2002(E)ISO/IEC 2002INTERNATIONAL STANDARD ISO/IEC16262Second edition2002-06-01Information technology ECMAScript language specification Technologies de linformation ECMAScript spcifications du langage Adopted by INCITS (InterNational Committee for Information Technology
2、 Standards) as an American National Standard.Date of ANSI Approval: 11/7/2002Published by American National Standards Institute,25 West 43rd Street, New York, New York 10036Copyright 2002 by Information Technology Industry Council (ITI).All rights reserved.These materials are subject to copyright cl
3、aims of International Standardization Organization (ISO), InternationalElectrotechnical Commission (IEC), American National Standards Institute (ANSI), and Information Technology Industry Council(ITI). Not for resale. No part of this publication may be reproduced in any form, including an electronic
4、 retrieval system, withoutthe prior written permission of ITI. All requests pertaining to this standard should be submitted to ITI, 1250 Eye Street NW,Washington, DC 20005.Printed in the United States of AmericaISO/IEC 16262:2002(E) PDF disclaimer This PDF file may contain embedded typefaces. In acc
5、ordance with Adobes licensing policy, this file may be printed or viewed but shall not be edited unless the typefaces which are embedded are licensed to and installed on the computer performing the editing. In downloading this file, parties accept therein the responsibility of not infringing Adobes
6、licensing policy. The ISO Central Secretariat accepts no liability in this area. Adobe is a trademark of Adobe Systems Incorporated. Details of the software products used to create this PDF file can be found in the General Info relative to the file; the PDF-creation parameters were optimized for pri
7、nting. Every care has been taken to ensure that the file is suitable for use by ISO member bodies. In the unlikely event that a problem relating to it is found, please inform the Central Secretariat at the address given below. ISO/IEC 2002 All rights reserved. Unless otherwise specified, no part of
8、this publication may be reproduced or utilized in any form or by any means, electronic or mechanical, including photocopying and microfilm, without permission in writing from either ISO at the address below or ISOs member body in the country of the requester. ISO copyright office Case postale 56 CH-
9、1211 Geneva 20 Tel. + 41 22 749 01 11 Fax + 41 22 749 09 47 E-mail copyrightiso.ch Web www.iso.ch Printed in Switzerland ii ISO/IEC 2002 All rights reservedISO/IEC 16262:2002(E) ISO/IEC 2002 All rights reserved iiiContents Page 1 Scope 1 2 Conformance1 3 Normative References.1 4 Overview.2 4.1 Web S
10、cripting.2 4.2 Language Overview .2 4.2.1 Objects .3 4.3 Terms and Definitions 4 4.3.1 Type4 4.3.2 Primitive Value4 4.3.3 Object .4 4.3.4 Constructor .4 4.3.5 Prototype 5 4.3.6 Native Object 5 4.3.7 Built-in Object .5 4.3.8 Host Object.5 4.3.9 Undefined Value.5 4.3.10 Undefined Type 5 4.3.11 Null Va
11、lue .5 4.3.12 Null Type 5 4.3.13 Boolean Value 5 4.3.14 Boolean Type .5 4.3.15 Boolean Object.5 4.3.16 String Value 6 4.3.17 String Type .6 4.3.18 String Object.6 4.3.19 Number Value.6 4.3.20 Number Type6 4.3.21 Number Object .6 4.3.22 Infinity .6 4.3.23 NaN 6 5 Notational Conventions 6 5.1 Syntacti
12、c and Lexical Grammars .6 5.1.1 Context-Free Grammars 6 5.1.2 The Lexical and RegExp Grammars 7 5.1.3 The Numeric String Grammar 7 5.1.4 The Syntactic Grammar7 5.1.5 Grammar Notation8 5.2 Algorithm Conventions.10 6 Source Text 11 7 Lexical Conventions11 7.1 Unicode Format-Control Characters 12 7.2 W
13、hite Space.12 7.3 Line Terminators 12 7.4 Comments13 7.5 Tokens14 ISO/IEC 16262:2002(E) iv ISO/IEC 2002 All rights reserved7.5.1 Reserved Words.14 7.5.2 Keywords 14 7.5.3 Future Reserved Words .14 7.6 Identifiers15 7.7 Punctuators 16 7.8 Literals16 7.8.1 Null Literals .16 7.8.2 Boolean Literals17 7.
14、8.3 Numeric Literals17 7.8.4 String Literals19 7.8.5 Regular Expression Literals21 7.9 Automatic Semicolon Insertion.22 7.9.1 Rules of Automatic Semicolon Insertion.22 7.9.2 Examples of Automatic Semicolon Insertion 23 8 Types.24 8.1 The Undefined Type.24 8.2 The Null Type.24 8.3 The Boolean Type24
15、8.4 The String Type24 8.5 The Number Type 25 8.6 The Object Type.26 8.6.1 Property Attributes26 8.6.2 Internal Properties and Methods 26 8.7 The Reference Type 29 8.7.1 GetValue (V).30 8.7.2 PutValue (V, W)30 8.8 The List Type30 8.9 The Completion Type.30 9 Type Conversion30 9.1 ToPrimitive .30 9.2
16、ToBoolean 31 9.3 ToNumber 31 9.3.1 ToNumber Applied to the String Type 31 9.4 ToInteger 34 9.5 ToInt32: (Signed 32 Bit Integer).34 9.6 ToUint32: (Unsigned 32 Bit Integer).35 9.7 ToUint16: (Unsigned 16 Bit Integer).35 9.8 ToString35 9.8.1 ToString Applied to the Number Type 36 9.9 ToObject.37 10 Exec
17、ution Contexts .37 10.1 Definitions.37 10.1.1 Function Objects.37 10.1.2 Types of Executable Code .37 10.1.3 Variable Instantiation 38 10.1.4 Scope Chain and Identifier Resolution .38 10.1.5 Global Object38 10.1.6 Activation Object.39 10.1.7 This .39 10.1.8 Arguments Object.39 10.2 Entering An Execu
18、tion Context 39 10.2.1 Global Code39 10.2.2 Eval Code .40 10.2.3 Function Code 40 11 Expressions40 ISO/IEC 16262:2002(E) ISO/IEC 2002 All rights reserved v11.1 Primary Expressions 40 11.1.1 The this Keyword.40 11.1.2 Identifier Reference 40 11.1.3 Literal Reference 40 11.1.4 Array Initialiser40 11.1
19、.5 Object Initialiser42 11.1.6 The Grouping Operator 43 11.2 Left-Hand-Side Expressions 43 11.2.1 Property Accessors 44 11.2.2 The new Operator44 11.2.3 Function Calls.45 11.2.4 Argument Lists45 11.2.5 Function Expressions .45 11.3 Postfix Expressions46 11.3.1 Postfix Increment Operator 46 11.3.2 Po
20、stfix Decrement Operator.46 11.4 Unary Operators.46 11.4.1 The delete Operator.46 11.4.2 The void Operator47 11.4.3 The typeof Operator 47 11.4.4 Prefix Increment Operator 47 11.4.5 Prefix Decrement Operator 47 11.4.6 Unary + Operator 47 11.4.7 Unary - Operator .48 11.4.8 Bitwise NOT Operator ( ).48
21、 11.4.9 Logical NOT Operator ( ! ).48 11.5 Multiplicative Operators48 11.5.1 Applying the * Operator .49 11.5.2 Applying the / Operator .49 11.5.3 Applying the % Operator .49 11.6 Additive Operators .50 11.6.1 The Addition operator ( + ) .50 11.6.2 The Subtraction Operator ( - ) .51 11.6.3 Applying
22、the Additive Operators ( +,- ) to Numbers .51 11.7 Bitwise Shift Operators.51 11.7.1 The Left Shift Operator ( ) 52 11.7.3 The Unsigned Right Shift Operator ( ) 52 11.8 Relational Operators 52 11.8.1 The Less-than Operator ( ) .53 11.8.3 The Less-than-or-equal Operator ( = ) 53 11.8.5 The Abstract R
23、elational Comparison Algorithm .54 11.8.6 The instanceof operator .54 11.8.7 The in operator .54 11.9 Equality Operators .55 11.9.1 The Equals Operator ( = ) 55 11.9.2 The Does-not-equals Operator ( != ).55 11.9.3 The Abstract Equality Comparison Algorithm 56 11.9.4 The Strict Equals Operator ( = ).
24、57 11.9.5 The Strict Does-not-equal Operator ( != ) .57 11.9.6 The Strict Equality Comparison Algorithm57 11.10 Binary Bitwise Operators .57 11.11 Binary Logical Operators .58 11.12 Conditional Operator ( ?: ).59 11.13 Assignment Operators .60 11.13.1 Simple Assignment ( = ) .60 ISO/IEC 16262:2002(E
25、) vi ISO/IEC 2002 All rights reserved11.13.2 Compound Assignment ( op= ) 60 11.14 Comma Operator ( , ).60 12 Statements61 12.1 Block.61 12.2 Variable statement .62 12.3 Empty Statement63 12.4 Expression Statement 63 12.5 The if Statement 64 12.6 Iteration Statements 64 12.6.1 The do-while Statement.
26、65 12.6.2 The while statement.65 12.6.3 The for Statement.65 12.6.4 The for-in Statement .66 12.7 The continue Statement .67 12.8 The break Statement67 12.9 The return Statement68 12.10 The with Statement 68 12.11 The switch Statement68 12.12 Labelled Statements 70 12.13 The throw statement 70 12.14
27、 The try statement.71 13 Function Definition 72 13.1 Definitions .73 13.1.1 Equated Grammar Productions73 13.1.2 Joined Objects73 13.2 Creating Function Objects73 13.2.1 Call75 13.2.2 Construct 75 14 Program 75 15 Native ECMAScript Objects 76 15.1 The Global Object 77 15.1.1 Value Properties of the
28、Global Object 77 15.1.2 Function Properties of the Global Object .77 15.1.3 URI Handling Function Properties79 15.1.4 Constructor Properties of the Global Object.83 15.1.5 Other Properties of the Global Object 84 15.2 Object Objects84 15.2.1 The Object Constructor Called as a Function 84 15.2.2 The
29、Object Constructor 84 15.2.3 Properties of the Object Constructor 84 15.2.4 Properties of the Object Prototype Object85 15.2.5 Properties of Object Instances .86 15.3 Function Objects 86 15.3.1 The Function Constructor Called as a Function.86 15.3.2 The Function Constructor.86 15.3.3 Properties of t
30、he Function Constructor.87 15.3.4 Properties of the Function Prototype Object 87 15.3.5 Properties of Function Instances88 15.4 Array Objects88 15.4.1 The Array Constructor Called as a Function 89 15.4.2 The Array Constructor 89 15.4.3 Properties of the Array Constructor89 15.4.4 Properties of the A
31、rray Prototype Object90 15.4.5 Properties of Array Instances .97 ISO/IEC 16262:2002(E) ISO/IEC 2002 All rights reserved vii15.5 String Objects.98 15.5.1 The String Constructor Called as a Function .98 15.5.2 The String Constructor .98 15.5.3 Properties of the String Constructor.99 15.5.4 Properties
32、of the String Prototype Object.99 15.5.5 Properties of String Instances 106 15.6 Boolean Objects.107 15.6.1 The Boolean Constructor Called as a Function .107 15.6.2 The Boolean Constructor .107 15.6.3 Properties of the Boolean Constructor .107 15.6.4 Properties of the Boolean Prototype Object.107 15
33、.6.5 Properties of Boolean Instances 108 15.7 Number Objects .108 15.7.1 The Number Constructor Called as a Function108 15.7.2 The Number Constructor108 15.7.3 Properties of the Number Constructor108 15.7.4 Properties of the Number Prototype Object .109 15.7.5 Properties of Number Instances.112 15.8
34、 The Math Object.112 15.8.1 Value Properties of the Math Object 112 15.8.2 Function Properties of the Math Object113 15.9 Date Objects 118 15.9.1 Overview of Date Objects and Definitions of Internal Operators .118 15.9.2 The Date Constructor Called as a Function .122 15.9.3 The Date Constructor .122
35、 15.9.4 Properties of the Date Constructor.123 15.9.5 Properties of the Date Prototype Object.124 15.9.6 Properties of Date Instances 131 15.10 RegExp (Regular Expression) Objects 131 15.10.1 Patterns 131 15.10.2 Pattern Semantics 133 15.10.3 The RegExp Constructor Called as a Function145 15.10.4 Th
36、e RegExp Constructor145 15.10.5 Properties of the RegExp Constructor146 15.10.6 Properties of the RegExp Prototype Object .146 15.10.7 Properties of RegExp Instances.147 15.11 Error Objects 148 15.11.1 The Error Constructor Called as a Function.148 15.11.2 The Error Constructor.148 15.11.3 Propertie
37、s of the Error Constructor 148 15.11.4 Properties of the Error Prototype Object 148 15.11.5 Properties of Error Instances149 15.11.6 Native Error Types Used in This Standard.149 15.11.7 NativeError Object Structure 149 16 Errors 151 Annex A (informative) Grammar Summary.152 A.1 Lexical Grammar .152
38、A.2 Number Conversions .156 A.3 Expressions .157 A.4 Statements.161 A.5 Functions and Programs163 A.6 Universal Resource Identifier Character Classes163 A.7 Regular Expressions164 Annex B (informative) Compatibility .166 B.1 Additional Syntax .166 B.1.1 Numeric Literals .166 ISO/IEC 16262:2002(E) vi
39、ii ISO/IEC 2002 All rights reservedB.1.2 String Literals .166 B.2 Additional Properties167 B.2.1 escape (string)167 B.2.2 unescape (string) .168 B.2.3 String.prototype.substr (start, length).168 B.2.4 Date.prototype.getYear ( )169 B.2.5 Date.prototype.setYear (year)169 B.2.6 Date.prototype.toGMTStri
40、ng ( )169 ISO/IEC 16262:2002(E) ISO/IEC 2002 All rights reserved ixForeword ISO (the International Organization for Standardization) and IEC (the International Electrotechnical Commission) form the specialized system for worldwide standardization. National bodies that are members of ISO or IEC parti
41、cipate in the development of International Standards through technical committees established by the respective organization to deal with particular fields of technical activity. ISO and IEC technical committees collaborate in fields of mutual interest. Other international organizations, governmenta
42、l and non-governmental, in liaison with ISO and IEC, also take part in the work. In the field of information technology, ISO and IEC have established a joint technical committee, ISO/IEC JTC 1. International Standards are drafted in accordance with the rules given in the ISO/IEC Directives, Part 3.
43、The main task of the joint technical committee is to prepare International Standards. Draft International Standards adopted by the joint technical committee are circulated to national bodies for voting. Publication as an International Standard requires approval by at least 75 % of the national bodie
44、s casting a vote. Attention is drawn to the possibility that some of the elements of this International Standard may be the subject of patent rights. ISO and IEC shall not be held responsible for identifying any or all such patent rights. ISO/IEC 16262 was prepared by ECMA (as ECMA-262) and was adop
45、ted, under a special “fast-track procedure”, by Joint Technical Committee ISO/IEC JTC 1, Information technology, Subcommittee SC 22, Programming languages, their environments and system software interfaces, in parallel with its approval by national bodies of ISO and IEC. This second edition cancels
46、and replaces the first edition (ISO/IEC 16262:1998), which has been technically revised. Annexes A and B of this International Standard are for information only. INTERNATIONAL STANDARD ISO/IEC 16262:2002(E) ISO/IEC 2002 All rights reserved 1Information technology ECMAScript language specification 1
47、Scope This International Standard defines the ECMAScript scripting language. 2 Conformance A conforming implementation of ECMAScript must provide and support all the types, values, objects, properties, functions, and program syntax and semantics described in this specification. A conforming implemen
48、tation of this International Standard shall interpret characters in conformance with the Unicode Standard, Version 2.1 or later, and ISO/IEC 10646-1 with either UCS-2 or UTF-16 as the adopted encoding form, implementation level 3. If the adopted ISO/IEC 10646-1 subset is not otherwise specified, it
49、is presumed to be the BMP subset, collection 300. If the adopted encoding form is not otherwise specified, it presumed to be the UTF-16 encoding form. A conforming implementation of ECMAScript is permitted to provide additional types, values, objects, properties, and functions beyond those described in this specification. In particular, a conforming implementation of ECMAScript is permitted to provide properties not described in this specification, and values for those properties, for objects that are described in this specific
copyright@ 2008-2019 麦多课文库(www.mydoc123.com)网站版权所有
备案/许可证编号:苏ICP备17064731号-1