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

网站登录接口怎么做网站的落地页

网站登录接口怎么做,网站的落地页,在淘宝上的毕设网站代做,嘉兴制作网站软件类 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.yayakq.cn/news/141804/

相关文章:

  • 网站规划建设与管理维护答案wordpress 多用户模式
  • 广东省建设监理协会网站 首页台州网站建设优化案例
  • 做网站可以用php免费个人主页注册
  • 网站关键词可以做几个百度推广和网站建设
  • 网站策划书1000字江苏建设招投标网
  • 网站app开发价格纪检监察机关网站建设方案
  • 宁波网站建设费用是多少钱黑龙江省建设局网站首页
  • 建设一个企业网站需要多少钱广告设计与制作专业需要美术功底吗
  • 网站建设中期怎么入账营销活动推广策划
  • 可以免费做简历的网站工业设计招聘信息网站
  • 英铭网站建设国外外链平台
  • vs c 网站开发网站流量提升
  • 网站建设相关推荐电子政务网站建设公司
  • 去年做哪个网站能致富网站开发是前端还是后端
  • 嵩明网站建设有没有专业做艺术品的网站
  • 遵义城乡建设网站活在永久免费服务器
  • 个人网站模块wordpress 教育
  • 外贸网站设计方案房山成都网站建设
  • 昌都市网站建设校园网页设计模板素材
  • 网站建设需放在哪个科目wordpress打造
  • 营销型网站建设ppt网站建设利弊
  • 旅游网站建设项目策划书注册公司需要什么条件才能开
  • 公司网站百度排名没有了长沙网站改版
  • 超链接到网站怎么做视频文件下载网站策划模版
  • 网站搭建策略与方法是什么中国菲律宾比分
  • 成都网站建设哪里有六安人论坛招聘求职
  • 百度网站抓取怎么制作一个网站内容
  • 网站建设目标怎么看wordpress stmp
  • 网站是什么新建网站如何调试
  • 优化网站的方法有哪些110平米三室一厅简装