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

javascript組合使用構(gòu)造函數(shù)模式和原型模式實(shí)例

 更新時(shí)間:2015年06月04日 10:55:26   作者:MaxOmnis  
這篇文章主要介紹了javascript組合使用構(gòu)造函數(shù)模式和原型模式的方法,通過一個(gè)簡(jiǎn)單實(shí)例分析了javascript構(gòu)造函數(shù)模式與原型模式的使用方法,需要的朋友可以參考下

本文實(shí)例講述了javascript組合使用構(gòu)造函數(shù)模式和原型模式的方法。分享給大家供大家參考。具體如下:

function testPrototype2(){
  function Person3(name, age, job){
    this.name=name;
    this.age=age;
    this.job=job;
    this.friends =["shelb", "court"];
  }
  Person3.prototype = {
    constructor:Person3,
    sayName:function(){
      alert(this.name);
    }
  }
  var person1 = new Person3("jack",10,"it");
  var person2 = new Person3("karry",1,"woker");
  person1.friends.push("tom");
  console.info(person1.friends);
  console.info(person2.friends);
  console.info(person1.friends==person2.friends);
  console.info(person1.sayName == person2.sayName);
}

希望本文所述對(duì)大家的javascript程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評(píng)論