所有的构造器都是对象,而并非所有的对象都是构造器.每个构造器都有一个用来实现原型继承、共享属性的Prototype属性。对象通过new 表达式创建;比如,new String("A String") 创建了一个String对象。没有通过new而直接调用构造器将有返回值,返回的类型将取决于构造器。例如String("A String")产生一个原始的类型的字符串而不是一个对象。
ECMAScript支持基于原型的继承。每个构造器都有一个与之关联的原型,而且通过此构造器创建的对象都有一个与构造器原型关联的隐式引用(称为,对象的原型)。进一步说,一个原型可能有一个对其原型的非空隐式引用……,这被称为,原型链。当一个引用指向对象的属性,这个引用指向原型链中的第一个对象的以此为名的属性。换句话说,第一次,这个直接关联的对象,将为这个属性被检查。如果这个对象包含以此为名的属性,这个属性就是引用指向的属性。如过这个对象不包含以此为名的属性,那么这个对象的原型将会被继续检查……
原文:
Object
ECMAScript does not contain proper classes such as those in C++, Smalltalk, or Java, but rather,supports constructors which create objects by executing code that allocates storage for the objects and initialises all or part of them by assigning initial values to their properties. All constructors are objects,but not all objects are constructors. Each constructor has a Prototype property that is used to implement prototype-based inheritance and shared properties. Objects are created by using constructors in new expressions; for example, new String("A String") creates a new String object. Invoking a constructor without using new has consequences that depend on the constructor. For example,String("A String") produces a primitive string, not an object.
ECMAScript supports prototype-based inheritance. Every constructor has an associated prototype, and every object created by that constructor has an implicit reference to the prototype (called the object's prototype) associated with its constructor. Furthermore, a prototype may have a non-null implicit reference to its prototype, and so on; this is called the prototype chain. When a reference is made to a property in an object, that reference is to the property of that name in the first object in the prototype chain that contains a property of that name. In other words, first the object mentioned directly is examined for such a property; if that object contains the named property, that is the property to which the reference refers; if that object does not contain the named property, the prototype for that object is examined next; and so on.
ECMAScript支持基于原型的继承。每个构造器都有一个与之关联的原型,而且通过此构造器创建的对象都有一个与构造器原型关联的隐式引用(称为,对象的原型)。进一步说,一个原型可能有一个对其原型的非空隐式引用……,这被称为,原型链。当一个引用指向对象的属性,这个引用指向原型链中的第一个对象的以此为名的属性。换句话说,第一次,这个直接关联的对象,将为这个属性被检查。如果这个对象包含以此为名的属性,这个属性就是引用指向的属性。如过这个对象不包含以此为名的属性,那么这个对象的原型将会被继续检查……
原文:
Object
ECMAScript does not contain proper classes such as those in C++, Smalltalk, or Java, but rather,supports constructors which create objects by executing code that allocates storage for the objects and initialises all or part of them by assigning initial values to their properties. All constructors are objects,but not all objects are constructors. Each constructor has a Prototype property that is used to implement prototype-based inheritance and shared properties. Objects are created by using constructors in new expressions; for example, new String("A String") creates a new String object. Invoking a constructor without using new has consequences that depend on the constructor. For example,String("A String") produces a primitive string, not an object.
ECMAScript supports prototype-based inheritance. Every constructor has an associated prototype, and every object created by that constructor has an implicit reference to the prototype (called the object's prototype) associated with its constructor. Furthermore, a prototype may have a non-null implicit reference to its prototype, and so on; this is called the prototype chain. When a reference is made to a property in an object, that reference is to the property of that name in the first object in the prototype chain that contains a property of that name. In other words, first the object mentioned directly is examined for such a property; if that object contains the named property, that is the property to which the reference refers; if that object does not contain the named property, the prototype for that object is examined next; and so on.
标签:
Javascript,对象
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
桃源资源网 Design By www.nqtax.com
暂无“Javascript 对象的解释”评论...
RTX 5090要首发 性能要翻倍!三星展示GDDR7显存
三星在GTC上展示了专为下一代游戏GPU设计的GDDR7内存。
首次推出的GDDR7内存模块密度为16GB,每个模块容量为2GB。其速度预设为32 Gbps(PAM3),但也可以降至28 Gbps,以提高产量和初始阶段的整体性能和成本效益。
据三星表示,GDDR7内存的能效将提高20%,同时工作电压仅为1.1V,低于标准的1.2V。通过采用更新的封装材料和优化的电路设计,使得在高速运行时的发热量降低,GDDR7的热阻比GDDR6降低了70%。