字符串的解构赋值

let [a,b,c,d,e] = 'Apple';
console.log(a); //A
console.log(b); //p
console.log(c); //p
console.log(d); //l
console.log(e); //e

const { length:len } = 'Hello'; //这边不能用[]因为{}才有属性
console.log(len); //5

const { length } = "Hello World!";
console.log(length); //12

 

相关文章:

  • 2021-07-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-08
  • 2021-06-30
猜你喜欢
  • 2022-01-23
  • 2021-11-06
  • 2021-12-21
  • 2022-03-04
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案