Blogger Information
Blog 28
fans 0
comment 0
visits 11592
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
11.3日作业
子墨吖ฅฅ
Original
320 people have browsed it
  1. // 数组的解构
  2. let [uname, email] = ['杨过', '123@qq.com']
  3. console.log(uname, email)
  4. ;[uname,...arrs] = ['小龙女', '123@qq.com' , '女']
  5. console.log(uname,...arrs)
  6. //对象的解构
  7. let show = (user) =>`${user.uname}: ( ${user.email} )`
  8. let user = { uname: '子墨', email: '3171275340@qq.com' }
  9. console.log(show(user));
  10. // 使用对象解构对上面代码进行重写
  11. show = ({username,email}) => `${username}: ( ${email} )`
  12. user = { username: '子墨', email: '123456@qq.com' }
  13. console.log(show(user));
  14. // 访问器属性
  15. const obj = {
  16. lesson: {
  17. name: '子墨',
  18. sex:'男',
  19. },
  20. get sex() {
  21. return {
  22. name: this.lesson.name,
  23. sex: this.lesson.sex,
  24. }
  25. },
  26. set sex(value){
  27. if(value === "男" || value === "女"){
  28. this.lesson.sex = value
  29. }else{
  30. console.log("性别必须是男或女")
  31. }
  32. }
  33. }
  34. console.log(obj.sex)
  35. obj.sex = "000"
  36. console.log(obj.sex)

运行图

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