4、概述 Overview
- ECMAScript is an object-oriented programming language for performing computations and manipulating computational objects within a host environment.
- ECMAScript was originally designed to be used as a scripting language, but has become widely used as a general purpose programming language.
- Therefore the core language is specified in this document apart from any particular host environment.
ECMAScript 是面向对象的通用型编程语言,需要在宿主环境中使用,但是ECMAScript 语言的核心是不涉及这些宿主环境的
4.1
Web Scripting
Each Web browser and server that supports ECMAScript supplies its own host environment, completing the ECMAScript execution environment.
- ECMAScript的两个宿主环境:web浏览器、web服务器,
- 不同的宿主环境提供了不同的web脚本:比如浏览器中提供window窗口对象供操作、服务器中提供request代表请求的对象来获取客户端请求内容
4.2 ECMAScript Overview
【1】何为基本数据类型?对象是什么?函数是什么?方法又是什么?
A primitive value is a member of one of the following built-in types:
Undefined
,
Null
,
Boolean
,
Number
, **String,**and **Symbol; **
an object is a member of the built-in type
Object
; and a function is a callable object.
A function that is associated with an object via a property is called a
method
.
【2】内置对象有哪些,如何分类
- objects that are fundamental to the runtime semantics of the language including
Object
,
Function
,
Boolean
,
Symbol
, and various **Error **objects;- objects that represent and manipulate numeric values including
Math
,
Number
, and
Date
;- the text processing objects **String **and
RegExp
;- objects that are indexed collections of values including **Array **;
- keyed collections including **Map **and **Set **objects;
- objects supporting structured data including the **JSON **object,
ArrayBuffer
, and
DataView
;- objects supporting control abstractions including generator functions and **Promise **objects;
- reflection objects including **Proxy **and
Reflect
.
【3】ECMAScript 定义的操作符_
operators
._ 还支持模块_
modules
_
_
4.2.1
Objects
- Each constructor is a function that has a property named **“prototype” **that is used to implement **prototype-based inheritance **and
shared properties
. Objects are created by using constructors in **new **expressions- Every object created by a constructor has an implicit reference (called the object’s
prototype
) to the value of its constructor’s **“prototype” **property. Furthermore, a prototype may have non-null implicit reference to its prototype, and so on; this is called the
prototype chain
- 对象怎么来的?
- 原型和原型链是什么?
4.2.2 The Strict Variant of ECMAScript
They might do so in the interests of security, to avoid what they consider to be error-prone features, to get enhanced error checking, or for other reasons of their choosing.
In support of this possibility, ECMAScript defines a strict variant of the language
出于一些场合的要求(代码安全性、健壮性),ECMAScript定义了一种语言的变体 – 严格模式。
在非严格模式下可用的代码在严格模式下可能会抛出错误
4.3 术语和定义
一些重要的术语和定义:
undefined value
primitive value used when a variable has not been assigned a value
null value
primitive value that represents the intentional absence of any object value
method
function that is the value of a property
4.4 本规范的组织(
Organization of This Specification)
该规范的组织结构
- Clause 5 defines the notational conventions used throughout the specification.
- Clauses 6−9 define the execution environment within which ECMAScript programs operate.
- Clauses 10−16 define the actual ECMAScript programming language including its syntactic encoding and the execution semantics of all language features.
- Clauses 17−26 define the ECMAScript standard library. It includes the definitions of all of the standard objects that are available for use by ECMAScript programs as they execute.
Clauses 10往后才是重点介绍ECMAScript语法和用法的。