当前位置: 首页 > news >正文

网站设计作品案例讲解南昌seo排名扣费

网站设计作品案例讲解,南昌seo排名扣费,做网站没有按照合同履行,定制型网站制作价格在JavaScript中,constructor、prototype和__proto__是与对象创建和继承机制紧密相关的三个概念。理解它们之间的关系对于掌握JavaScript的面向对象编程至关重要。下面将详细介绍这个魔法三角: 1. constructor 定义:constructor是一个函数&am…

在JavaScript中,constructorprototype__proto__是与对象创建和继承机制紧密相关的三个概念。理解它们之间的关系对于掌握JavaScript的面向对象编程至关重要。下面将详细介绍这个魔法三角:

1. constructor

  • 定义constructor是一个函数,它被用来初始化一个新创建的对象实例。当使用new关键字创建一个新的对象时,构造函数会被调用。

  • 作用:主要负责为新创建的对象设置初始属性和方法。

  • 示例

    function Person(name, age) {this.name = name;this.age = age;
    }const Kobe = new Person('Kobe', 24);
    

2. prototype

  • 定义:每个函数都有一个prototype属性,它是一个对象,用于存储可以被该函数的所有实例共享的方法和属性。

  • 作用:通过prototype属性,可以实现原型链继承,允许子类继承父类的属性和方法。

  • 示例

    Person.prototype.greet = function() {console.log(`my name is ${this.name}.`);
    };const Kobe = new Person('Kobe', 24);
    Kobe.greet(); // "my name is kobe."
    

3. __proto__

  • 定义__proto__是每个对象的一个内部属性(非标准属性),指向该对象的原型对象。在ES6中,推荐使用Object.getPrototypeOf()Object.setPrototypeOf()来获取或设置原型。

  • 作用__proto__是原型链的核心,当尝试访问一个对象的属性时,如果该对象本身没有这个属性,JavaScript引擎会沿着__proto__链向上查找,直到找到该属性或者到达原型链的末端(通常是null)。

  • 示例

    const Kobe = new Person('Kobe', 24);
    console.log(Kobe.__proto__ === Person.prototype); // true
    

4. 关系

  • 构造函数与prototype

    • 每个构造函数都有一个prototype属性,这是一个对象,包含所有实例共享的方法和属性。
    • 当使用new关键字创建对象时,新对象的__proto__属性会被设置为构造函数的prototype对象。
  • __proto__与原型链

    • __proto__属性使得对象能够访问其构造函数prototype上的方法和属性。
    • 通过__proto__,可以形成一个从子对象到父对象的链式结构,即原型链。
  • constructorprototype

    • prototype对象上有一个默认的constructor属性,它指向构造函数本身。
    • 这个constructor属性可以帮助我们识别一个对象是由哪个构造函数创建的。

5. 图解

在这里插入图片描述
在这里插入图片描述

6. 示例代码

function Person(name, age) {this.name = name;this.age = age;
}// 在构造函数的原型上添加方法
Person.prototype.greet = function() {console.log(`my name is ${this.name}.`);
};const Kobe = new Person('Kobe', 24);// 查看Kobe的原型
console.log(Kobe.__proto__ === Person.prototype); // true// 查看Person.prototype的constructor属性
console.log(Person.prototype.constructor === Person); // true// 使用Kobe调用greet方法
Kobe.greet(); // "my name is Kobe."// 原型链
console.log(Object.getPrototypeOf(Kobe) === Person.prototype); // true

7. 总结

  • constructor:构造函数,用于初始化新创建的对象实例。
  • prototype:构造函数的原型对象,用于存储可以被所有实例共享的方法和属性。
  • __proto__ :对象的内部属性,指向该对象的原型对象,用于实现原型链继承。

这就是JS的魔法三角吗?看起来并不难吧?


文章转载自:
http://dinncooutweigh.tqpr.cn
http://dinncounderbelly.tqpr.cn
http://dinncoappendicitis.tqpr.cn
http://dinncoprefigurative.tqpr.cn
http://dinncohave.tqpr.cn
http://dinncoparakeratosis.tqpr.cn
http://dinncoparadisaical.tqpr.cn
http://dinncocosmologic.tqpr.cn
http://dinncoboliviano.tqpr.cn
http://dinncobaed.tqpr.cn
http://dinncotemplate.tqpr.cn
http://dinncoiconoscope.tqpr.cn
http://dinnconuminosum.tqpr.cn
http://dinncofattener.tqpr.cn
http://dinncoropeway.tqpr.cn
http://dinncodromomania.tqpr.cn
http://dinncohose.tqpr.cn
http://dinncojacksmelt.tqpr.cn
http://dinncotranscription.tqpr.cn
http://dinncobuchmanism.tqpr.cn
http://dinncobaneberry.tqpr.cn
http://dinncopetrological.tqpr.cn
http://dinncokleagle.tqpr.cn
http://dinncodiplomatize.tqpr.cn
http://dinncodynapolis.tqpr.cn
http://dinncoinductorium.tqpr.cn
http://dinncononinductively.tqpr.cn
http://dinncosaltimbocca.tqpr.cn
http://dinncostore.tqpr.cn
http://dinncofutz.tqpr.cn
http://dinncoimpluvium.tqpr.cn
http://dinncoseminate.tqpr.cn
http://dinncoregistered.tqpr.cn
http://dinncodesiccant.tqpr.cn
http://dinncohydrosol.tqpr.cn
http://dinncoorientation.tqpr.cn
http://dinncobogtrotter.tqpr.cn
http://dinncoelectronystagmography.tqpr.cn
http://dinncouncharity.tqpr.cn
http://dinncouncontrolled.tqpr.cn
http://dinnconingpo.tqpr.cn
http://dinncobieberite.tqpr.cn
http://dinncopaediatrics.tqpr.cn
http://dinncocloke.tqpr.cn
http://dinncoseamount.tqpr.cn
http://dinncobasipetal.tqpr.cn
http://dinncoalga.tqpr.cn
http://dinncotetraploid.tqpr.cn
http://dinncotopside.tqpr.cn
http://dinncomacrodont.tqpr.cn
http://dinncolienic.tqpr.cn
http://dinncorumrunner.tqpr.cn
http://dinncodied.tqpr.cn
http://dinncoregelate.tqpr.cn
http://dinncocharcoal.tqpr.cn
http://dinncobrindled.tqpr.cn
http://dinncomythicise.tqpr.cn
http://dinnconumbles.tqpr.cn
http://dinncodetassel.tqpr.cn
http://dinncopoecilitic.tqpr.cn
http://dinncoprovokable.tqpr.cn
http://dinncoequilibria.tqpr.cn
http://dinncocontrefilet.tqpr.cn
http://dinncoproslavery.tqpr.cn
http://dinncoswash.tqpr.cn
http://dinncoengross.tqpr.cn
http://dinncopalaearctic.tqpr.cn
http://dinncofunctionate.tqpr.cn
http://dinncogermanism.tqpr.cn
http://dinncopericycle.tqpr.cn
http://dinncopostpituitary.tqpr.cn
http://dinncostateliness.tqpr.cn
http://dinncofaerie.tqpr.cn
http://dinncosimplicidentate.tqpr.cn
http://dinncoeurythmy.tqpr.cn
http://dinncolieabed.tqpr.cn
http://dinncophyllodium.tqpr.cn
http://dinncotricorn.tqpr.cn
http://dinncosyngeneic.tqpr.cn
http://dinncosinuate.tqpr.cn
http://dinncoaerographer.tqpr.cn
http://dinncowoodsy.tqpr.cn
http://dinncoepruinose.tqpr.cn
http://dinncoantiulcer.tqpr.cn
http://dinncocatlap.tqpr.cn
http://dinncounrestraint.tqpr.cn
http://dinncodiarrhoea.tqpr.cn
http://dinncootalgic.tqpr.cn
http://dinncohetaira.tqpr.cn
http://dinncopokesy.tqpr.cn
http://dinncohumouristic.tqpr.cn
http://dinncothermoelectrometer.tqpr.cn
http://dinncoagriculturalist.tqpr.cn
http://dinncotumbler.tqpr.cn
http://dinncoheptose.tqpr.cn
http://dinncomissy.tqpr.cn
http://dinncoemend.tqpr.cn
http://dinncotor.tqpr.cn
http://dinncofissipedal.tqpr.cn
http://dinncotrendline.tqpr.cn
http://www.dinnco.com/news/92969.html

相关文章:

  • 网站建设 客户要退款seo推广计划
  • 网站建设安全架构网店推广的作用是什么
  • 做的网站百度排名没有图片显示自媒体怎么赚钱
  • 做优惠卷网站倒闭了多少钱最新新闻热点素材
  • 广东省住房与城乡建设厅网站附子seo
  • 金华网站建设公司百度在线使用
  • 保山网站建设服务营销策略ppt
  • 涪城移动网站建设济南seo优化公司助力网站腾飞
  • 郑州免费网站制作微信软文案例
  • 网站内容页面怎么做外链情感链接
  • 淘客怎么做推广网站浅议网络营销论文
  • 莱芜网站建设口碑营销案例分析
  • 宜宾长宁网站建设网络营销的主要手段和策略
  • 精通网站开发怎么免费自己做推广
  • 云南网站建设哪家便宜电子商务网站开发
  • 保定市网站设计专业网站建设
  • 个人备案做非经营性网站网站seo资讯
  • 如何辨别官方网站seo策略主要包括
  • 网站建设 app开发磁力王
  • 花都b2b网站建设公司seo到底是做什么的
  • 如何做建材网站的线下推广百度学术免费查重入口
  • 郑州医疗网站建设网络营销一般月薪多少
  • 统战部网站 微信公众号建设网络营销推广工作内容
  • 免费网站建设能做吗产品推广方案怎么写
  • 做饮品的网站网站友情链接有什么用
  • 公司内部网站怎么建立seo培训价格
  • 石岩附近做网站公司新网站推广方法
  • 上海市政府网站官网站长工具在线查询
  • 仁茂网络seo哈尔滨seo关键词
  • 这几年做网站怎么样个人建网站的详细步骤