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

产品设计师网站seo推广的网站和平台有哪些

产品设计师网站,seo推广的网站和平台有哪些,网站设计师认证培训,做网站视频博彩类 ES6新引入class关键字具有正式定义类的能力。 类定义:类声明和类表达式。 // 类声明 class Person {} // 类表达式 const Animal class {}; 类定义与函数定义的不同: 1:函数声明可以提升,类定义不能 2:函数受函数…

ES6新引入class关键字具有正式定义类的能力。

类定义:类声明和类表达式。

// 类声明
class Person {} 
// 类表达式
const Animal = class {};

类定义与函数定义的不同:

                                                1:函数声明可以提升,类定义不能

                                                2:函数受函数作用域限制,类受块作用域限制

//提升与否
console.log(FunctionDeclaration); // FunctionDeclaration() {} 
function FunctionDeclaration() {} 
console.log(FunctionDeclaration); // FunctionDeclaration() {}
console.log(ClassDeclaration); // ReferenceError: ClassDeclaration is not defined 
class ClassDeclaration {} 
console.log(ClassDeclaration); // class ClassDeclaration {}
//作用域限制范围function FunctionDeclaration() {} class ClassDeclaration {} 
} 
console.log(FunctionDeclaration); // FunctionDeclaration() {} 
console.log(ClassDeclaration); // ReferenceError: ClassDeclaration is not defined

类构造函数:constructor关键字用于在类定义块内部创建类的构造函数。

实例化,使用new调用类的构造函数会执行如下操作:

(1) 在内存中创建一个新对象。
(2) 这个新对象内部的 [[Prototype]] 指针被赋值为构造函数的 prototype 属性。
(3) 构造函数内部的 this 被赋值为这个新对象(即 this 指向新对象)。
(4) 执行构造函数内部的代码(给新对象添加属性)。
(5) 如果构造函数返回非空对象,则返回该对象;否则,返回刚创建的新对象。
class Animal {} 
class Person { constructor() { console.log('person ctor'); } 
} 
class Vegetable { constructor() { this.color = 'orange'; } 
} 
let a = new Animal(); 
let p = new Person(); // person ctor 
let v = new Vegetable(); 
console.log(v.color); // orange

类继承:使用extends关键字,可以继承任何拥有[[Construct]]和原型的对象。

class Vehicle {} 
// 继承类
class Bus extends Vehicle {} 
let b = new Bus(); 
console.log(b instanceof Bus); // true 
console.log(b instanceof Vehicle); // true 
function Person() {} 
// 继承普通构造函数
class Engineer extends Person {} 
let e = new Engineer(); 
console.log(e instanceof Engineer); // true 
console.log(e instanceof Person); // true

super():

class Vehicle { static identify() { console.log('vehicle'); } 
} 
class Bus extends Vehicle { static identify() { super.identify(); } 
} 
Bus.identify(); // vehicle

                super 只能在派生类构造函数和静态方法中使用

class Vehicle{
constructor() {
super();
//SyntaxError:'super' keyword unexpected}
}

                不能单独引用 super 关键字,要么用它调用构造函数,要么用它引用静态方法

class Vehicle {} 
class Bus extends Vehicle { constructor() { console.log(super); // SyntaxError: 'super' keyword unexpected here } 
}

                调用 super()会调用父类构造函数,并将返回的实例赋值给 this

class Vehicle {} 
class Bus extends Vehicle { constructor() { super(); console.log(this instanceof Vehicle); } 
} 
new Bus(); // true

                super()的行为如同调用构造函数,如果需要给父类构造函数传参,则需要手动传入

class Vehicle { constructor(licensePlate) { this.licensePlate = licensePlate; } 
} 
class Bus extends Vehicle { constructor(licensePlate) { super(licensePlate); } 
} 
console.log(new Bus('1337H4X')); // Bus { licensePlate: '1337H4X' }

                如果没有定义类构造函数,在实例化派生类时会调用 super(),而且会传入所有传                  给派生类的参数

class Vehicle { constructor(licensePlate) { this.licensePlate = licensePlate; } 
} 
class Bus extends Vehicle {} 
console.log(new Bus('1337H4X')); // Bus { licensePlate: '1337H4X' }

                在类构造函数中,不能在调用 super()之前引用 this

class Vehicle {} 
class Bus extends Vehicle { constructor() { console.log(this); } 
} 
new Bus(); 
// ReferenceError: Must call super constructor in derived class 
// before accessing 'this' or returning from derived constructor

                如果在派生类中显式定义了构造函数,则要么必须在其中调用 super(),要么必须                  在其中返回一个对象

class Vehicle {} 
class Car extends Vehicle {} 
class Bus extends Vehicle { constructor() { super(); } 
} 
class Van extends Vehicle { constructor() { return {}; } 
} 
console.log(new Car()); // Car {} 
console.log(new Bus()); // Bus {} 
console.log(new Van()); // {}

http://www.hkea.cn/news/957451/

相关文章:

  • 怎么注册公司支付宝账号seo求职信息
  • 多语言网站怎么做网络推广平台公司
  • 山东公司注册网站怎样写营销策划方案
  • 河北省香河县建设局网站中国互联网协会
  • 北京丰台区网站建设游戏推广赚佣金的平台
  • 网站没排名怎么办搜索引擎广告优化
  • wordpress内容主题模板网络网站推广选择乐云seo
  • 电子元器件商城网站建设百度开户怎么开
  • 企业网站开发基本流程百度博客收录提交入口
  • 甘特图模板关于网站建设微信营销模式
  • 网站建设的swot分析长尾关键词挖掘精灵
  • 发布自己的做家教的网站网店运营推广登录入口
  • b s网站系统如何做性能测试百度推广运营怎么做
  • 洛阳seo外包公司费用seo的中文意思
  • 政府网站建设遵循的原则seo网站内容优化
  • java做网站具体步骤邵阳seo优化
  • 自己做的网站如何放进服务器今天今日头条新闻
  • 男装网站的网站建设背景惠州seo按天计费
  • 如何快速提高网站排名互联网项目推广
  • icp备案网站名称更改成都网站设计
  • 企业网站建设需求分析seo排名资源
  • python基础教程雪峰东莞搜索seo网站关键词优化
  • b2b网站开发供应商小程序开发教程全集免费
  • 用自己的手机做网站外链网站是什么
  • 市场调研公司介绍网站推广优化公司
  • 玉溪人民政府网站建设现状新网站seo
  • 湖南餐饮网站建设2023北京封控了
  • 重庆网站设计人员外贸网站搭建推广
  • 局域网内的网站建设西安网站建设公司排名
  • 普通网站报价多少中南建设集团有限公司