ES6知识点整理之----解构赋值----字符串

1、字符串也可以解构赋值。因为字符串被转换成了一个类似数组的对象。

const [a, b, c, d, e] = 'hello';
a // "h"
b // "e"
c // "l"
d // "l"
e // "o"
 
let {length : len} = 'hello';
len // 5

猜你喜欢

转载自www.cnblogs.com/adhehe/p/9641260.html