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

扫码支付做进商城网站情感营销的十大案例

扫码支付做进商城网站,情感营销的十大案例,wordpress网站公告,开发公司购买开发公司的房屋如何报税一、主要区别 ES5 的继承实质上是先创建子类的实例对象, 然后再将父类的方法添加 到 this 上(Parent.apply(this)) . ES6 的继承机制完全不同, 实质上是先创建父类的实例对象 this(所以必 须先调用父类的 super()方法…

一、主要区别

  1. ES5 的继承实质上是先创建子类的实例对象, 然后再将父类的方法添加
    到 this 上(Parent.apply(this)) .

  2. ES6 的继承机制完全不同, 实质上是先创建父类的实例对象 this(所以必
    须先调用父类的 super()方法) , 然后再用子类的构造函数修改 this。

  3. ES5 的继承时通过原型或构造函数机制来实现。

  4. ES6 通过 class 关键字定义类, 里面有构造方法, 类之间通过 extends 关
    键字实现继承。

  5. 子类必须在 constructor 方法中调用 super 方法, 否则新建实例报错。 因
    为子类没有自己的 this 对象, 而是继承了父类的 this 对象, 然后对其进行加工。
    如果不调用 super 方法, 子类得不到 this 对象。

  6. 注意 super 关键字指代父类的实例, 即父类的 this 对象。

  7. 注意: 在子类构造函数中, 调用 super 后, 才可使用 this 关键字, 否则
    报错。

function 声明会提升, 但不会初始化赋值。 Foo 进入暂时性死区, 类似于 let、
const 声明变量。

const bar = new Bar();  
// it's ok  
function Bar() {  this.bar = 42;  
}
const foo = new Foo();  
// ReferenceError: Foo is not defined
class Foo {  constructor() {  this.foo = 42;  }  
}  

二、class 声明内部会启用严格模式。

// 引用一个未声明的变量 function Bar() {  
baz = 42;  
// it's ok}const bar = new Bar();  
class Foo {  constructor() {  fol = 42;  // ReferenceError: fol is not defined  }  
}const foo = new Foo();  

三、class 的所有方法(包括静态方法和实例方法) 都是不可枚举的。

// 引用一个未声明的变量 
function Bar() {  this.bar = 42;
}
Bar.answer = function() { return 42;  
};  
Bar.prototype.print = function() {  console.log(this.bar);  
};  
const barKeys = Object.keys(Bar);  
// ['answer']
const barProtoKeys = Object.keys(Bar.prototype);  
// ['print']class Foo {  constructor() {  this.foo = 42;  } static answer() {  return 42;  } print() {  console.log(this.foo);  }
}
const fooKeys = Object.keys(Foo);  
// []
const fooProtoKeys = Object.keys(Foo.prototype);  
// []  

四、class 的所有方法( 包括静态方法和实例方法) 都没有原型对象 prototype, 所以也没有 constructor, 不能使用 new 来调用。

function Bar() {  this.bar = 42;  
}
Bar.prototype.print = function() {  console.log(this.bar);  
};  
const bar = new Bar();  
const barPrint = new bar.print();  // it's ok
class Foo {  constructor() {  this.foo = 42;  } print() {  console.log(this.foo);  }
}
const foo = new Foo();  
const fooPrint = new foo.print();  
// TypeError: foo.print is not a constructor  

必须使用 new 调用 class。

function Bar() {  this.bar = 42;  
}
// it's ok
const bar = Bar();  class Foo {  constructor() {  this.foo = 42;  }
}
const foo = Foo();  
// TypeError: Class constructor Foo cannot be invoked without 'new'  

五、class 内部无法重写类名。

function Bar() {  Bar = 'Baz';  // it's ok this.bar = 42;  
}
const bar = new Bar();  
// Bar: 'Baz'  
// bar: Bar {bar: 42} class Foo {  constructor() {  this.foo = 42;  Foo = 'Fol';  // TypeError: Assignment to constant variable  }
}
const foo = new Foo();  
Foo = 'Fol';  
// it's ok
http://www.khdw.cn/news/32721.html

相关文章:

  • 天长街道两学一做网站百度度小店申请入口
  • 策划网站设计网站在线客服系统源码
  • 做公司网站推广sem投放
  • web网站源码百度百度一下你就知道主页
  • 自动做设计的网站搜索引擎推广
  • sae wordpress主题厦门seo起梦网络科技
  • 邢台学校网站建设报价广州百度搜索优化
  • 占酷设计网站官网入口企业管理软件
  • 本地怎样做网站搜索引擎seo优化怎么做
  • 手机app开发制作推荐上海网络营销seo
  • wordpress模版怎么弄今日头条seo
  • 公司网站开发的核心技术搜狗seo排名软件
  • 团购网站APP怎么做深圳市企业网站seo营销工具
  • 网站排名优化首页技能培训学校
  • 专业商城网站建设宝安网站建设
  • 保定市网站销售和设计免费二级域名分发平台
  • wordpress整站源码带数据安装百度
  • 中小企业网络组建佛山seo网站排名
  • p2p贷款网站制作竞价推广开户多少钱
  • 网站建设需要租用什么全国疫情高峰时间表最新
  • 做货代用什么网站找客户互联网搜索引擎
  • 必应网站首页的图片怎么做的百度软件优化排名
  • 优质高等职业院校建设网站沈阳seo网站关键词优化
  • 青岛网站关键词优化公司网络做推广广告公司
  • 主流搭建网站投广告哪个平台好
  • 网站制作应该选什么平台推广是什么
  • 手机 网站开发软件网站友情链接购买
  • 昆明做网站排名网络营销策划方案的目的
  • 有哪些做的好的汽配零配件网站哪有网页设计公司
  • 做5173这样的网站要多少人我国网络营销现状分析