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

          javascript prototype object

          Posted on 2007-05-28 15:50 change 閱讀(305) 評論(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.

           
          主站蜘蛛池模板: 陆良县| 临汾市| 海口市| 常宁市| 堆龙德庆县| 石渠县| 鸡西市| 英山县| 韩城市| 六枝特区| 金坛市| 固阳县| 包头市| 山西省| 新和县| 河西区| 凤山市| 呈贡县| 贵港市| 金溪县| 通辽市| 达州市| 安溪县| 游戏| 吉木萨尔县| 大姚县| 武夷山市| 台东县| 新邵县| 林口县| 罗江县| 松原市| 忻城县| 西宁市| 如东县| 淳安县| 湘阴县| 鄂州市| 习水县| 福贡县| 大关县|