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

dremrever怎么做网站网页开发和网站开发

dremrever怎么做网站,网页开发和网站开发,上海闵行区怎么样,wordpress更换主题方法一、主要区别 ES5 的继承实质上是先创建子类的实例对象#xff0c; 然后再将父类的方法添加 到 this 上#xff08;Parent.apply(this)#xff09; . ES6 的继承机制完全不同#xff0c; 实质上是先创建父类的实例对象 this#xff08;所以必 须先调用父类的 super()方法…一、主要区别 ES5 的继承实质上是先创建子类的实例对象 然后再将父类的方法添加 到 this 上Parent.apply(this) . ES6 的继承机制完全不同 实质上是先创建父类的实例对象 this所以必 须先调用父类的 super()方法 然后再用子类的构造函数修改 this。 ES5 的继承时通过原型或构造函数机制来实现。 ES6 通过 class 关键字定义类 里面有构造方法 类之间通过 extends 关 键字实现继承。 子类必须在 constructor 方法中调用 super 方法 否则新建实例报错。 因 为子类没有自己的 this 对象 而是继承了父类的 this 对象 然后对其进行加工。 如果不调用 super 方法 子类得不到 this 对象。 注意 super 关键字指代父类的实例 即父类的 this 对象。 注意 在子类构造函数中 调用 super 后 才可使用 this 关键字 否则 报错。 function 声明会提升 但不会初始化赋值。 Foo 进入暂时性死区 类似于 let、 const 声明变量。 const bar new Bar(); // its 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; // its 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(); // its 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; } // its 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; // its 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; // its ok
http://www.dnsts.com.cn/news/136604.html

相关文章:

  • 哪里购买网站空间wordpress 替换google字体
  • 北京互联网公司建网站软件开发项目管理办法
  • 网站建设前台后台wordpress 多域名绑定域名
  • 做一个什么网站好安卓手机怎么搭建网页
  • 旅游门户网站建设方案虚拟机安装wordpress
  • 项目网长沙官网seo服务
  • 企业做网站需要注意什么问题织梦网站搬家
  • 宿州市住房和城乡建设局网站唐山企业网站建设公司
  • 长沙 做网站网站制作公司 信科网络
  • 哪里有网站设计的公司wordpress主题制作slider
  • 电脑外设网站建设论文网站开发文档是什么概念
  • 服务器 做网站网站建设服务费入
  • php做网站的分站杭州公司注册费用
  • 网站问责建设书微信开发者平台工具
  • 做冷库的网站网站导航你一定会回来感谢我的
  • php做网站有哪些优点wordpress倒计时代码
  • 抚顺网站建设wordpress自动重命名
  • 网站建设公司营销话术企业管理咨询公司名称大全
  • 新网站建设需要什么公众号app下载
  • 沈阳建设银行网站js网站开发
  • 国外网站怎么浏览百度趋势搜索
  • 一个考试网站怎么做苏州实力做网站公司有哪些
  • 建设文明网 联盟网站的中铁建设集团内网登录
  • 抚顺网站建设上海龙雨建设工程有限公司网站
  • 建设一个网站平台的费用吗加强门户网站建设的讲话
  • 暴走漫画网站建设目的百度推广怎么推
  • 建设网站的网站叫什么男软件公司是做什么的
  • 南通网站托管青岛网络科技公司排名
  • 网站淘宝客怎么做的公司部门英文缩写简称大全
  • wordpress设计网站关键词排名优化易下拉系统