<!DOCTYPE html>
<html lang="ch-CN">
<head>
    <meta charset="UTF-8">
    <title>transfer</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
</head>
<body>

<script type="text/javascript">
// 变量,常量
function test() {
    let a = 10;
    const b = 20;
    console.log(a);
    console.log(b);
}
test();

// 数组的解构赋值
function example() {
    return [1, 2, 3];
}
var [a, b, c] = example();
console.log('a:' + a);
console.log('b:' + b);
console.log('c:' + c);

// 对象的解构赋值
function examples() {
    return {
        foo: 1,
        baz: 2
    };
}
var {foo, baz} = examples();
console.log('foo:' + foo);
console.log(baz);
</script>
</script>
</body>
</html>

小渝人儿
1.1k 声望850 粉丝

前端工程师