ES6(一)

1.在es6中对this进行了修复

2. 数组展开

接收剩余参数:

剩余参数必最后一个


function show(a,b,...arr) {

console.log(a,b,arr)



show(1,2,3,4,5,6,7,8)

 

展开数组:


let arr1 = [1,2,3];

let arr2 = [4,5,6];

let arr = [...arr1,...arr2];

3.系统对象

Array

map 映射 1对1 forEach 遍历 循环一遍 filter 过滤


  aItems
  .filter(item=>item.loc==cur_loc)
  .filter(item=>item.price>=60 && item.price<100);

reduce 减少 多对1

String

字符串模板

startsWith //判断开头 endsWith //判断结尾

JSON

1.标准写法{"key": "aaa", "key2": 12}

2.JSON对象stringify // json转标准字符创parse //将字符串转回json

 

*异步处理

Promise (先new,后.then,有两个参数resolve //失败,reject //成功)

Promise.all

async/await //用于解决事务的先后顺序问题


async function show(){

let date1 = await $.ajax({url: 'data/1.json'},dateType: 'json');

let date2 = await $.ajax({url: 'data/1.json'},dateType: 'json');

let date3 = await $.ajax({url: 'data/1.json'},dateType: 'json');


}

 

posted @ 2019-07-30 15:21  德豪  阅读(145)  评论(0编辑  收藏  举报