Blogger Information
Blog 42
fans 0
comment 0
visits 15340
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
0722class 类介绍数组与对象解构
小言
Original
280 people have browsed it

class 类介绍

js中没有类,其实都是函数

  1. class Demo1 {
  2. //公共成员
  3. username = '测试';
  4. //构造方法,实例初始化
  5. constructor(name,email){
  6. //自由属性
  7. this.name = name;
  8. this.email = email;
  9. }
  10. //共享 成员;原型成员
  11. getInfo(){
  12. return `${this.name} : (${this.email})`;
  13. }
  14. //静态成员
  15. static status = 'enabled';
  16. }

数组与对象解构

  1. let [username, useremail] = ['测试中', '333@qq.com'];
  2. console.log(username, useremail);
  3. console.log('----------------------');
  4. //更新
  5. [username, useremail] = ['测试中中', '333@qq.com'];
  6. console.log(username, useremail);
  7. console.log('----------------------');

  1. let {id, lesson, soure} = {id:1,lesson:'js',soure:88};
  2. console.log(id, lesson, soure);
  3. ({id, lesson, soure} = {id:2,lesson:'php',soure:88});
  4. console.log(id, lesson, soure);
  5. let {id: itemid, num, price} = {id:3, num:10, price:1234};
  6. console.log(itemid, num, price);

Correcting teacher:PHPzPHPz

Correction status:qualified

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!