inheritPrototypal.js
                                                            生活随笔
收集整理的這篇文章主要介紹了
                                inheritPrototypal.js
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.                        
                                
                            
                            
                            // 原型式繼承
// 其基本思路是借助原型可以基于已有的對象創(chuàng)建新的對象function object(o){function F(){}F.prototype = o;return new F();
}var person = {name: "Tom",friends:  ["Jack", "John", "Kim"]
};
var David = object(person);
David.name = "David";
David.friends.push("Amy");
console.log(David.friends);// ["Jack", "John", "Kim", "Amy"]
var Rob = object(person);
Rob.name = "Rob";
console.log(Rob.friends);// ["Jack", "John", "Kim", "Amy"] 
 
更多專業(yè)前端知識,請上 【猿2048】www.mk2048.com
                        
                        
                        ?
更多專業(yè)前端知識,請上 【猿2048】www.mk2048.com
總結
以上是生活随笔為你收集整理的inheritPrototypal.js的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
 
                            
                        - 上一篇: css实现div内一段文本的两端对齐
- 下一篇: coffee.js
