es6常用特性
默认值参数
function test(x = 5) { let x = 1 // 报错 const x = 2 // 报错 }// 报错 Duplicate parameter name function test(x, x, y = 1) { ... }function test(num = 1) { console.log((typeof num) + ', num的值为: ' + num) } test() // number, num的值为: 1 test(undefined) // number, num的值为: 1 test('') // string, num的值为: test(null) // object, num的值为: nullfunction test(name, height, msg = name + ' height is ' + height) { return [name, height, msg] } test('MuYi086', 'nihao') // ["MuYi086", "nihao", "MuYi086 height is nihao"] test('MuYi086', 'nihao', 'hello world') // ["MuYi086", "nihao", "hello world"]function test(x, y = 5, z) { return [x, y, z] } test(1, , 2) // 报错(function (a) {}).length // 1 (function (a = 5) {}).length // 0 (function (a, b = 1, c) {}).length // 1
变量声明: let和const
模板字符串
标签模板字面量
箭头函数
扩展运算符
rest
for of
解构
super
Promise
Generator Function
class
export 和 import
参考
Last updated
Was this helpful?