所有的构造器都是对象,而并非所有的对象都是构造器.每个构造器都有一个用来实现原型继承、共享属性的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.
推荐整理分享Javascript 对象的解释(javascript 对象的this指向),希望有所帮助,仅作参考,欢迎阅读内容。
文章相关热门搜索词:javascript对象的属性和方法,JavaScript对象的构造函数包括什么,javascript对象的种类,javascript对象的种类,javascript对象的种类,javascript 对象的this指向,javascript 对象的this指向,javascript对象的属性和方法,内容如对您有帮助,希望把文章链接给更多的朋友!
js继承 Base类的源码解析 //timestamp:Tue,May::/*base2.js-copyright,
[推荐]javascript 面向对象技术基础教程 结果呢,看了大半天,有了一个大概的了解,细细一回味,好像什么都没懂...这篇文章是参考javascript-thedefinitiveguide,5thedition第7,8,9章而写成的,我也会尽量按
小型js框架veryide.librar源代码 /**CopyrightVeryIDE,-*