ECMAScript笔记

阅读数:1393 发布时间:2016-05-28 18:49:13

作者:zzl005 标签: ECMA 朱忠来005 javascript 翻译

An ECMAScript object is a collection of properties each with zero or more attributes that determine how each property can be used—...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.

一个 ECMAScript 对象是带有 0 或多个属性的 property 的集合,这些属性对每个 property 进行了说明。
properties 是一个容器,这个容器可以包含其他对象,原始值(primitive value),或者函数。
原始值(primitive value)是以下内置类型的成员之一:

object 是剩下的内置对象成员之一。
函数是可调用的对象。
方法是一个通过 property 和对象相关联的函数。

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.....

ECMAScript 定义了一系列实现了 ECMAScript 定义的的预置对象。这些对象包括:全局类型对象,对象类型对象,函数类型对象,数组类型对象,字符串类型对象等等

Instead objects may be created in various ways including via a literal notation or via constructors which create objects and then execute code that initialises all or part of them by assigning initial values to their properties.

可以用不同的方式创建 instead objects ,包括通过字面量的方式,或者构造器的方式(这种方式创建对象时通过设定初始值来执行全部或部分的初始化)。

Each constructor is a function that has a property named “prototype” that is used to implement prototype-based inheritance and shared properties.

每个构造器都是一个包含 prototype 属性的函数,这个 prototype 属性是用来实现原型继承和属性共享。
通过 new 对象(); 的这种方式创建实体对象。

invoking a constructor without using new has consequences that depend on the constructor. For example, Date() produces a string representation of the current date and time rather than an object.

调用构造器可以不通过 new 对象 执行构造,比如 Date(),可以产生一个字符串用来指代当前的日期和时间,但这种方式产生的并不是一个对象。

a prototype may have a non-null implicit reference to its prototype, and so on; this is called the prototype chain.

一个原型可能会有一个非空的隐式指向,指向它自己的原型,并且一个连着一个的这么一直指下去。

这样就能形成一个原型链?

总结:

  1. ECMAScript 对象是 property 的集合,property 包含了 0 个或多个属性

  2. Properties 是一个容器,可以包含原始值(primitive value)、其他对象或者函数

    • 内置类型的成员包括:
      • 原始值(primitive value)
      • object
    • 其中原始值(primitive value)包括:
      • Undefined
      • Null
      • Boolean
      • Number
      • String
  3. 函数也是对象,可以被调用。
  4. ECMAScript 预置对象:

    • 全局类型对象
    • 对象类型对象
    • 函数类型对象
    • 数组类型对象,
    • 字符串类型对象
    • ...
  5. Instead objects 两种方式:
    • 字面量方式
    • 构造器的方式
  6. 构造器:
    • 一个包含 prototype 属性的函数
      • 这个 prototype 属性是用来实现原型继承属性共享
  7. 创建实体对象
    • new 对象();
  8. 原型链
    • 一个原型可能会有一个非空的隐式指向,指向它自己的原型
    • 这个原型的原型也有一个非空的隐式指向它自己的原型
    • 一个接一个的指下去
    • 形成了原型链
  9. 方法(method)
    • 函数(function)作为一个对象的某个属性的值时,这个函数叫做方法(method)

相关文章推荐: