<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title></title>
</head>
<body>
<div id="list">
</div>
<script>
//函数声明
function abc() {};
//函数表示
var bbc = function() {}
//剪头函数
const cbc = (x, y) => {
return x + y;
};
let dbc = () => {};
console.log(cbc(1, 1));
let c = '';
const ABC = "";
// 模板字符
let a = ``;
// 剪头函数
let b = () => {};
// 数组解构赋值
let [a, b, c] = [1, 2, 3];
let [a, [, , b], c] = [1, [2, 3, 4], 5];
const [a = 1, b = 2] = [];
// 函数也可以解构
const fun = () => {
console.log(1);
return 2;
};
const [x = fun()] = [];
// 函数的解构赋值
const array = [1, 2];
const add = arr => arr[0] + arr[1];
const [a = 0, b = 0] = [x + y];
console.log(add(array)); //3
// 对象的取值
const {
user: u,
age: a
} = {
user: 'wu',
age: 40
};
console.log(u, a);
// 对象字面量 就是对象字面量的写法。
const ob = {
name: 'wulei',
age: 40
};
//对象字面量 方括号语法的增强。
let name = 'wulei';
const ren = {};
// 方法1
ren.name = 'sun';
// 方法2
ren[name] = 18;
// 方法3
ren = {
[name]: 30
};
console.log(ren); //{wulei:18};
</script>
</body>
</html>