4.2 Language Overview 語言概述

4.2 Language Overview

The following is an informal overview of ECMAScript—not all parts of the language are described. This overview is not part of the standard proper.
ECMAScript is object-based: basic language and host facilities are provided by objects, and an ECMAScript program is a cluster of communicating objects. An ECMAScript object is a collection of properties each with zero or more attributes that determine how each property can be used—for example, when the Writable attribute for a property is set to false, any attempt by executed ECMAScript code to change the value of the property fails. Properties are containers that hold other objects, primitive values, or functions. A primitive value is a member of one of the following built-in types: Undefined, Null, Boolean, Number, and String; an object is a member of the remaining built-in type Object; and a function is a callable object. A function that is associated with an object via a property is a method.
 
4.2 語言概述
下面是一個ECMAScript的非正式概述—並非語言的所有部分都會提到。這份概述並不是標準本身的一部分。
ECMAScript是基於物件的:基本語言和主機功能都是由物件提供,ECMAScript程式是一群可互相溝通的物件。ECMAScript物件是一群屬性的集合,每個屬性都有0個或多個特徵,這些特徵決定每個屬性能夠如何被使用。譬如說,當某個屬性的可寫特徵被設成false,任何藉由執行ECMAScript程式碼來改變屬性值的企圖都會失效。屬性是個容器,能夠裝載其他的物件、原始值或是函式。原始值是下面內建型態中的一個成員(原始值是下面內建型態的其中一種):未定義(Undefined), 空(Null), 布林(Boolean), 數值(Number), and 字串(String);物件是其餘內建型態物件中的成員,函式是一個可呼叫的物件。經由屬性連結到物件的函式稱之為方法(method)。
 
ECMAScript defines a collection of built-in objects that round out the definition of ECMAScript entities. These built-in objects include the global object, the Object object, the Function object, the Array object, the String object, the Boolean object, the Number object, the Math object, the Date object, the RegExp object, the JSON object, and the Error objects Error, EvalError, RangeError, ReferenceError, SyntaxError, TypeError and URIError.
ECMAScript also defines a set of built-in operators. ECMAScript operators include various unary operations, multiplicative operators, additive operators, bitwise shift operators, relational operators, equality operators, binary bitwise operators, binary logical operators, assignment operators, and the comma operator.
ECMAScript syntax intentionally resembles Java syntax. ECMAScript syntax is relaxed to enable it to serve as an easy-to-use scripting language. For example, a variable is not required to have its type declared nor are types associated with properties, and defined functions are not required to have their declarations appear textually before calls to them.
 
ECMAScript定義了一組內建物件,這組內建物件完成了ECMAScript本質的定義。這些內建物件包含了全局物件、Object物件、函式物件、陣列物件、字串物件、布林物件、數值物件、數學物件、日期物件、正規表達是物件、JSON物件以及錯誤物件,其中錯誤物件包含下面幾種Error, EvalError, RangeError, ReferenceError, SyntaxError, TypeError and URIError。ECMAScript 也定義了一組內建的運算子。ECMAScript 運算子包含了各種的單元運算子、乘法運算子、加法運算子、位元寬位移運算子、關係運算子、相等運算子、二進位位元寬運算子、二進位邏輯運算子、指定運算子、逗號運算子。
ECMAScript語法有意地類似於Java語法。ECMAScript語法鬆散,使它能成為一個易於使用的腳本描述語言。譬如說,變數並不需要宣告其型別,或是與屬性相關之型別,而函式定義時,函式的宣告也不需要出現在函式呼叫之前。
 
 

  按個讚!~支持本站!~

FB推薦載入中