码迷,mamicode.com
首页 > 其他好文 > 详细

ES6(一)

时间:2019-07-30 15:52:54      阅读:84      评论:0      收藏:0      [点我收藏+]

标签:gif   事务   red   pre   解决   string   reac   map   func   

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‘);


}

 

ES6(一)

标签:gif   事务   red   pre   解决   string   reac   map   func   

原文地址:https://www.cnblogs.com/dehao/p/11270270.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!