## ES7和ES8語法
### ES7
> 1.includes()
> 2.冪運算符( **)
### ES8
> 1.padStart(),padEnd()
> 2.Object.values和Object.entries
> 3.Object.getOwnPropertyDescriptors
> 4.函數參數列表和調用中的尾逗號
> 5.異步函數(Async Functions)
### includes
~~~
var array1 = [1, 2, 3];
console.log(array1.includes(2));
// expected output: true
var pets = ['cat', 'dog', 'bat'];
console.log(pets.includes('cat'));
// expected output: true
console.log(pets.includes('at'));
// expected output: false
~~~
### 冪運算
~~~
let a = 7 ** 12
let b = 2 ** 7
console.log(a === Math.pow(7,12)) // true
console.log(b === Math.pow(2,7)) // true
~~~
### padStart(),padEnd()
~~~
'x'.padStart(5, 'ab') // 'ababx'
'x'.padStart(4, 'ab') // 'abax'
'x'.padEnd(5, 'ab') // 'xabab'
'x'.padEnd(4, 'ab') // 'xaba'
~~~
如果原字符串的長度,等于或大于指定的最小長度,則返回原字符串。
~~~
'xxx'.padStart(2, 'ab') // 'xxx'
'xxx'.padEnd(2, 'ab') // 'xxx'
~~~
### Object.values和Object.entries
~~~
const obj = { foo: 'bar', baz: 42 };
Object.values(obj)
// ["bar", 42]
~~~
~~~
const obj = { foo: 'bar', baz: 42 };
Object.entries(obj)
// [ ["foo", "bar"], ["baz", 42] ]
~~~
### Object.getOwnPropertyDescriptors
~~~
const obj = {
foo: 123,
get bar() { return 'abc' }
};
Object.getOwnPropertyDescriptors(obj)
// { foo:
// { value: 123,
// writable: true,
// enumerable: true,
// configurable: true },
// bar:
// { get: [Function: get bar],
// set: undefined,
// enumerable: true,
// configurable: true } }
~~~
### 函數參數列表和調用中的尾逗號
~~~
function clownsEverywhere(
param1,
param2,
) { /* ... */ }
clownsEverywhere(
'foo',
'bar',
);
~~~
### 異步函數(Async Functions)
async 函數是什么?一句話,它就是 Generator 函數的語法糖
~~~
var timer = new Promise((resolve,reject) => {
setTimeout(() => {
resolve(123)
},1000)
})
function* gen(){
var f = yield timer
}
var g = gen();
g.next().value.then((x) => {
console.log(x)
})
~~~
~~~
var f = new Promise((resolve,reject) => {
setTimeout(() => {
resolve(123)
}, 1000)
})
f.then((s) => {
console.log(s)
})
~~~
~~~
var f = new Promise((resolve,reject) => {
setTimeout(() => {
resolve(123)
}, 1000)
})
async function test() {
let test = await f
console.log(test)
}
test()
~~~
- Less
- 課程規劃
- Less概述
- 變量
- 混合
- 嵌套
- 繼承
- 導入
- 函數
- 其他
- 實戰
- ES6
- 課程規劃
- ES6概述
- let和const命令
- 變量的解構賦值
- 字符串擴展
- 函數擴展
- 數組擴展
- Set和Map數據結構
- Symbol
- Generator 函數
- Promise對象
- Class語法
- Module 的語法
- ES7和ES8
- 實戰
- VUE
- 課程規劃
- vue概述
- vue實例
- 模版語法
- 計算屬性和偵聽器
- Class和Style的綁定
- 條件渲染
- 列表渲染
- 事件處理
- 表單輸入綁定
- 組件基礎
- 過渡和動畫
- 自定義指令
- 過濾器
- 響應式原理
- 實戰課程
- Node
- 課程規劃
- 課程概述
- node入門實例
- 模塊系統
- 回調函數
- 全局對象
- 常用模塊介紹
- 常用模塊介紹-1
- 常用模塊介紹-2
- 常用模塊介紹-3
- npm使用
- express的使用
- express的使用-1
- webpack基礎
- 實戰
- 微信小程序
- 課程規劃
- 課程概述
- 基本配置和生命周期
- wxml模版
- wxss
- wxs
- 組件
- 微信API
- 自定義組件開發
- 實戰小程序
- Element
- 課程規劃
- 課程概述
- 特性介紹
- 組件介紹-基礎組件
- 組件介紹-表單組件
- 組件介紹-數據展示組件
- 組件介紹-提示組件
- 組件介紹-導航組件
- 組件介紹-其他組件
- 綜合案例