ECMAScript Language Specification Reference number ECMA-123:2009 آ© Ecma International 2009 ECMA-262

  • View
    1

  • Download
    0

Embed Size (px)

Text of ECMAScript Language Specification Reference number ECMA-123:2009 آ© Ecma International 2009...

  • Reference number

    ECMA-123:2009

    © Ecma International 2009

    ECMA-262 5.1 Edition / June 2011

    ECMAScript Language

    Specification

  • COPYRIGHT PROTECTED DOCUMENT

    © Ecma International 2011

  • Copyright notice

    Copyright © 2011 Ecma International Ecma International Rue du Rhone 114 CH-1204 Geneva Tel: +41 22 849 6000 Fax: +41 22 849 6001 Web: http://www.ecma-international.org This document and possible translations of it may be copied and furnished to others, and derivative works that comment on or otherwise explain it or assist in its implementation may be prepared, copied, published, and distributed, in whole or in part, without restriction of any kind, provided that the above copyright notice and this section are included on all such copies and derivative works. However, this document itself may not be modified in any way, including by removing the copyright notice or references to Ecma International, except as needed for the purpose of developing any document or deliverable produced by Ecma International (in which case the rules applied to copyrights must be followed) or as required to translate it into languages other than English. The limited permissions granted above are perpetual and will not be revoked by Ecma International or its successors or assigns. This document and the information contained herein is provided on an "AS IS" basis and ECMA INTERNATIONAL DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY OWNERSHIP RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE." Software License All Software contained in this document ("Software)" is protected by copyright and is being made available under the "BSD License", included below. This Software may be subject to third party rights (rights from parties other than Ecma International), including patent rights, and no licenses under such third party rights are granted under this license even if the third party concerned is a member of Ecma International. SEE THE ECMA CODE OF CONDUCT IN PATENT MATTERS AVAILABLE AT http://www.ecma- international.org/memento/codeofconduct.htm FOR INFORMATION REGARDING THE LICENSING OF PATENT CLAIMS THAT ARE REQUIRED TO IMPLEMENT ECMA INTERNATIONAL STANDARDS*. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the authors nor Ecma International may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE ECMA INTERNATIONAL "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ECMA INTERNATIONAL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

    http://www.ecma-international.org/

  • COPYRIGHT PROTECTED DOCUMENT

    © Ecma International 2011

  • © Ecma International 2011 i

    Contents Page

    Introduction ....................................................................................................................................................... vii

    1 Scope ............................................................................................................................................................. 1

    2 Conformance ................................................................................................................................................ 1

    3 Normative references .................................................................................................................................. 1

    4 Overview ....................................................................................................................................................... 1 4.1 Web Scripting ............................................................................................................................................ 2 4.2 Language Overview .................................................................................................................................. 2 4.2.1 Objects .................................................................................................................................................... 3 4.2.2 The Strict Variant of ECMAScript ......................................................................................................... 4 4.3 Terms and definitions ............................................................................................................................... 4

    5 Notational Conventions ............................................................................................................................... 7 5.1 Syntactic and Lexical Grammars............................................................................................................. 7 5.1.1 Context-Free Grammars ........................................................................................................................ 7 5.1.2 The Lexical and RegExp Grammars ..................................................................................................... 8 5.1.3 The Numeric String Grammar ............................................................................................................... 8 5.1.4 The Syntactic Grammar ......................................................................................................................... 8 5.1.5 The JSON Grammar ............................................................................................................................... 9 5.1.6 Grammar Notation .................................................................................................................................. 9 5.2 Algorithm Conventions .......................................................................................................................... 11

    6 Source Text ................................................................................................................................................. 13

    7 Lexical Conventions .................................................................................................................................. 13 7.1 Unicode Format-Control Characters ..................................................................................................... 14 7.2 White Space ............................................................................................................................................. 14 7.3 Line Terminators ..................................................................................................................................... 15 7.4 Comments ................................................................................................................................................ 16 7.5 Tokens ...................................................................................................................................................... 17 7.6 Identifier Names and Identifiers............................................................................................................. 17 7.6.1 Reserved Words ................................................................................................................................... 18 7.7 Punctuators ............................................................................................................................................. 19 7.8 Literals ...................................................................................................................................................... 19 7.8.1 Null Literals ........................................................................................................................................... 19 7.8.2 Boolean Literals ................................................................................................................................... 20 7.8.3 Numeric Literals ................................................................................................................................... 20 7.8.4 String Literals ....................................................................................................................................... 22 7.8.5 Regular Expression Literals ................................................................................................................ 24 7.9 Automatic Semicolon Insertion ............................................................................................................. 26 7.9.1 Rules of Automatic Semicolon Insertion ........................................................................................... 26 7.9.2 Examples o

Recommended

View more >