前端——1

哪些东西?
1.JS东西
ES6
面向对象、闭包、模块
正则、json
2.Node.js
原生
框架——express、koa
数据库
实例
3.自动化
gulp
webpack
4.三大框架
Angular
Vue
React
5.微信
公号
小程序
6.混合App
RN
weex
7.系统优化、安全

--------------------------------------------------------------------------------

ES6

ECMAScript

ES2015(ES6.0)

最新2019(ES10)

--------------------------------------------------------------------------------

ES6
方便->工程性

--------------------------------------------------------------------------------

变量

var:
1.可以重复声明
2.没有块级作用域
3.不能限制

let 声明变量
const 声明常量

1.禁止重复声明
2.控制修改
3.支持块级作用域

--------------------------------------------------------------------------------

作用域
1.传统
函数级

2.ES6
块级

语法块
{}

if(){

}

for(){

}

{

}

--------------------------------------------------------------------------------

解构赋值
{a: 12, b: 5, c: 33}
[12, 5, 8]

1.左右两边一样
2.右边得是个东西

--------------------------------------------------------------------------------

函数
1.箭头函数
function (参数){

}

(参数)=>{}

如果,有且仅有1个参数,()也可以省
如果,有且仅有1条语句-return,{}可以省


修复this


2.参数展开

剩余参数——必须是最后一个
展开数组——就跟把数组的东西写在那儿一样

--------------------------------------------------------------------------------

系统对象

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
parse

--------------------------------------------------------------------------------

*异步处理
Promise
async/await

--------------------------------------------------------------------------------

异步操作?
异步——多个操作可以一起进行,互不干扰
同步——操作一个个进行


$.ajax({
url: 'data/1.json',
dataType: 'json',
success(data1){
$.ajax({
url: 'data/2.json',
dataType: 'json',
success(data2){
$.ajax({
url: 'data/3.json',
dataType: 'json',
success(data3){
console.log(data1, data2, data3);
}
});
}
});
}
});

let data1=$.ajax('data/1.json');
let data2=$.ajax('data/2.json');
let data3=$.ajax('data/3.json');

--------------------------------------------------------------------------------

Promise

Promise.all([
p1,
p2,
p3
]).then();

async/await

async function xxx(){
let a=12;
let b=5;

let data=await promise;

...

alert(a+b);
}

let xxx=async ()=>{

}

--------------------------------------------------------------------------------

猜你喜欢

转载自www.cnblogs.com/wholeworld/p/10982724.html
今日推荐