posts - 29, comments - 0, trackbacks - 0, articles - 0
            BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

          javascript prototype object

          Posted on 2007-05-28 15:50 change 閱讀(309) 評論(0)  編輯  收藏

          from: :OReilly.JavaScript.The.Definitive.Guide.5th.Edition.Aug.2006

           It turns out that every JavaScript object includes an internal reference to another object, known as its prototype object. Any properties of the prototype appear to be properties of an object for which it is the prototype. Another way of saying this is that a JavaScript object inherits properties from its prototype.

          In the previous section, I showed that the new operator creates a new, empty object and then invokes a constructor function as a method of that object. This is not the complete story, however. After creating the empty object, new sets the prototype of that object. The prototype of an object is the value of the prototype property of its constructor function. All functions have a prototype property that is automatically created and initialized when the function is defined. The initial value of the prototype property is an object with a single property. This property is named constructor and refers back to the constructor function with which the prototype is associated. (You may recall the constructor property from Chapter 7 ; this is why every object has a constructor property.) Any properties you add to this prototype object will appear to be properties of objects initialized by the constructor.

           
          主站蜘蛛池模板: 柳江县| 南投市| 久治县| 南丹县| 融水| 平和县| 贵州省| 兰考县| 江油市| 孝义市| 内黄县| 桃园县| 乌兰浩特市| 宁蒗| 承德县| 济宁市| 宁明县| 金川县| 会理县| 舞钢市| 华容县| 闽侯县| 克山县| 特克斯县| 隆昌县| 河南省| 甘孜| 龙山县| 民和| 浦北县| 株洲县| 韩城市| 南康市| 峨眉山市| 晋城| 西和县| 呼图壁县| 奉化市| 麻江县| 江孜县| 富宁县|