欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Javascript 對(duì)象的解釋

 更新時(shí)間:2008年11月24日 21:39:31   作者:  
ECMAScript沒有像C++,Smalltalk,或者java中那樣規(guī)矩的類,可是它支持通過執(zhí)行分配空間的代碼來創(chuàng)建對(duì)象、并初始化對(duì)象所有或者一部分屬性的構(gòu)造器。
所有的構(gòu)造器都是對(duì)象,而并非所有的對(duì)象都是構(gòu)造器.每個(gè)構(gòu)造器都有一個(gè)用來實(shí)現(xiàn)原型繼承、共享屬性的Prototype屬性。對(duì)象通過new 表達(dá)式創(chuàng)建;比如,new String("A String") 創(chuàng)建了一個(gè)String對(duì)象。沒有通過new而直接調(diào)用構(gòu)造器將有返回值,返回的類型將取決于構(gòu)造器。例如String("A String")產(chǎn)生一個(gè)原始的類型的字符串而不是一個(gè)對(duì)象。
ECMAScript支持基于原型的繼承。每個(gè)構(gòu)造器都有一個(gè)與之關(guān)聯(lián)的原型,而且通過此構(gòu)造器創(chuàng)建的對(duì)象都有一個(gè)與構(gòu)造器原型關(guān)聯(lián)的隱式引用(稱為,對(duì)象的原型)。進(jìn)一步說,一個(gè)原型可能有一個(gè)對(duì)其原型的非空隱式引用……,這被稱為,原型鏈。當(dāng)一個(gè)引用指向?qū)ο蟮膶傩裕@個(gè)引用指向原型鏈中的第一個(gè)對(duì)象的以此為名的屬性。換句話說,第一次,這個(gè)直接關(guān)聯(lián)的對(duì)象,將為這個(gè)屬性被檢查。如果這個(gè)對(duì)象包含以此為名的屬性,這個(gè)屬性就是引用指向的屬性。如過這個(gè)對(duì)象不包含以此為名的屬性,那么這個(gè)對(duì)象的原型將會(huì)被繼續(xù)檢查……
原文:
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.

相關(guān)文章

  • 改變javascript函數(shù)內(nèi)部this指針指向的三種方法

    改變javascript函數(shù)內(nèi)部this指針指向的三種方法

    javascript 的this 值,真的是非常的莫名奇妙。我一直被搞的很頭暈,也許正是這個(gè)this,讓大多數(shù)人感覺js 非常的莫名其妙。
    2010-04-04
  • javascript 寫類方式之六

    javascript 寫類方式之六

    這篇開始會(huì)分析流行的js庫之寫類方式。各種庫的寫類方式雖然千奇百怪,但仍然逃離不了本質(zhì)---用構(gòu)造函數(shù)和原型 來組裝類。
    2009-07-07
  • javascript復(fù)制對(duì)象使用說明

    javascript復(fù)制對(duì)象使用說明

    javascript復(fù)制對(duì)象使用說明,需要的朋友可以參考下。
    2011-06-06
  • JavaScript RegExp方法獲取地址欄參數(shù)(面向?qū)ο?

    JavaScript RegExp方法獲取地址欄參數(shù)(面向?qū)ο?

    個(gè)人認(rèn)為循環(huán)用得多不是什么好事。這里推薦一種利用OO思想加上RegExp的方法,使它更靈活、高效。
    2009-03-03
  • javascript new后的constructor屬性

    javascript new后的constructor屬性

    new后的constructor屬性使用說明,需要的朋友可以參考下。
    2010-08-08
  • javascript 面向?qū)ο蟮腏avaScript類

    javascript 面向?qū)ο蟮腏avaScript類

    這一節(jié)來說下緊接著的一個(gè)概念——類。雖然JavaScript中沒有class關(guān)鍵字,但作為開發(fā)人員我們一定要有這個(gè)思想。在C#中類可以分為實(shí)例類和靜態(tài)類,JavaScript亦然。
    2010-05-05
  • 寫自已的js類庫需要的核心代碼

    寫自已的js類庫需要的核心代碼

    眾所周知,用jQuery的extend方法,可以很方便的實(shí)現(xiàn)繼承和對(duì)象拷貝,我們可以把它拿過來自己用
    2012-07-07
  • 面向?qū)ο蟮腏avascript之二(接口實(shí)現(xiàn)介紹)

    面向?qū)ο蟮腏avascript之二(接口實(shí)現(xiàn)介紹)

    接口是面向?qū)ο驤avascript工具箱中最有用的特性之一。我們都知道GOF在設(shè)計(jì)模式中說到:面向接口編程,而非面向?qū)崿F(xiàn)編程
    2012-01-01
  • 最新評(píng)論