架构学习资料
由于篇幅限制小编,pdf文档的详解资料太全面,细节内容实在太多啦,所以只把部分知识点截图出来粗略的介绍,每个小节点里面都有更细化的内容!
//2 允许重复声明
var b = 20;
var b = 30;
console.info(b); //30
//3 允许重新赋值
b = 40;
console.info(b); //40
//4 允许只声明不赋值
var c;
console.info©; //undefined
* let
//1 let声明的变量,不允许变量提升
/*
{
let a = 10;
}
console.info(a); //异常, a is not defined
*/
//2 存在暂时性死区 : 在块代码中,所有的变量都是局部变量 (必须先声明,再使用)
/*
var b = 10;
{
console.info(b); //b is not defined
let b = 20;
}
*/
//3 不允许重复声明
/*
var c = 10;
let c = 20; //Identifier ‘c’ has already been declared (变量c已经声明了)
*/
/**/
//4 允许重新赋值
let d = 10;
d = 20;
console.info(d); //20
//5 允许只声明不赋值
let e;
console.info(e); //undefined
* const
const a = 10;
//1. 不允许提升
/*
{
const b = 10;
}
console.info(b) //b is not defined
*/
//2. 存在暂时性死区
/*
var c = 10;
{
console.info(c) //c is not defined
const c = 20;
}
*/
//3. 不允许重复声明
/*
const a = 20; //Identifier ‘a’ has already been declared
*/
//4. 不允许重新赋值
/*
a = 20; //Assignment to constant variable.
*/
//5. 不允许只声明不赋值
//const d; // Missing initializer in const declaration
1.2解构赋值
---------------
* ES6允许按照一定模式,从数组和对象中提取值,对变量进行赋值,这被称为解构(Destructuring)
* ES5获得对象数据的语法,如下:
const people = {
name: 'lux',
age: 20
}
const name = people.name; //ES5写法
const age = people.age;
console.log(name + ’ ‐‐‐ ’ + age)
* 对象解构:从一个对象一次性解析出多个属性给不同变量
* 解构的变量名,必须与属性名保持一致。
var person = {
username : "jack",
password : "1234",
"show" : function(){
console.info("show执行了");
},
course : {
en : 100,
math : 99
}
}
//es5获得数据
console.info( person.username )
console.info( person.password )
person.show()
//对象解构
let {username,password,show, age } = person;
console.info(username) //jack
console.info(password) //1234
console.info( show ) //[Function: show]
console.info( age ) //undefined
show(); //show执行了
//结构对象中的对象
let {course} = person;
console.info(course) //{ en: 100, math: 99 }
let {course : {en, math}} = person;
console.info(en) //100
* 数组解构:按照数组排序依次赋值
// 声明数组
var arr = [‘江苏’,‘宿迁’];
// 从数组中解构成员
let [province, city] = arr;
console.info(province)
console.info(city)
//交换2个变量
let x = 10;
let y = 20;
console.info(x = ${x} , y = ${y}
);
[y,x] = [x,y];
console.info(x = ${x} , y = ${y}
);
* 常见应用:遍历Map (稍后讲解)
var map = new Map();
map.set(‘first’, ‘hello’);
map.set(‘second’, ‘world’);
for (let [key, value] of map) {
console.log(key + " is " + value);
}
// first is hello
// second is world
* 常见应用:模块内容的提取(稍后讲解)
const { SourceMapConsumer, SourceNode } = require(“source-map”);
1.3函数参数名默认值
------------------
* 在声明函数参数时,给参数设置默认值
function log(x, y = ‘World’) { //y参数设置默认值
console.log(x, y);
}
log(‘Hello’) // Hello World
log(‘Hello’, ‘China’) // Hello China
log(‘Hello’, ‘’) // Hello
* 默认值和解构
function fun1({x = “x1” , y } = {y : “y2”}){
return [x , y] ;
}
console.info( fun1() ); //[ ‘x1’, ‘y2’ ]
console.info( fun1({}) ); //[ ‘x1’, undefined ] ,
//{} 覆盖 {y:"y2"} ,解构默认值,x=x1,y=undefined
* 默认值应用:参数必填
function fun2(args = new Error(“参数必须填写”)){
console.info(args);
}
fun2();
fun2(“abc”);
1.4箭头函数的this
--------------------
* this对象:
* function函数中this表示当前对象
* 箭头函数没有自己的this,箭头函数的this看外层的是否有函数,
* 如果有,外层函数的this就是内部箭头函数的this,
* 如果没有,在浏览器环境下this是window;在node.js环境下为指定环境(例如:vue)
* 创建 demo03\_2.js 文件
var name=“外部”;
var user = {
name : '内部',
show : function(){
console.info(this.name)
},
show2 : () => {
console.info(this.name)
console.info(user.name)
}
}
user.show() //内部
user.show2() //undefined、内部
* 创建 demo03\_3.html
<meta charset="UTF-8">
<title>Document</title>
1.5Map数据结构(Map集合)
-------------------------
* JavaScript的对象(Object),本质上是键值对的集合(Hash结构),但是传统上只能用字符串当作键。这给它的使用带来了很大的限制。
* ES6提供了Map数据结构。它类似于对象,也是键值对的集合,但是“键”的范围不限于字符串。
1.6Set数据结构(Set集合)
------------------------
* ES6提供了新的数据结构Set。它类似于数组,但是成员的值都是唯一的,没有重复的值。
//Set集合:存储唯一数据
var set = new Set();
set.add(1);
set.add(2);
set.add(3);
set.add(2);
set.add(1);
console.info( set ); //Set { 1, 2, 3 }
* 过滤数组中重复的数据
var arr = [2, 3, 5, 4, 5, 2, 2];
//方式1
var set2 = new Set();
// 1) 遍历数组,将数据添加到set
arr.map( s => set2.add(s) );
// 2) 遍历set集合,添加到新数组
var arr2 = [];
set2.forEach( v => arr2.push(v) );
console.info( arr2 ); //[ 2, 3, 5, 4 ]
//方式2
var arr3 = [ … new Set(arr) ]
console.info( arr3 ); //[ 2, 3, 5, 4 ]
1.7for...of遍历
---------------------
* 在JavaScript中,数据的遍历存在多种,在ES6中提供了for…of ,用于统一所有数据结构的遍历。
//准备数据
var arr4 = [‘x’,‘y’,‘z’];
var map4 = new Map();
map4.set(“a”,“1111”);
map4.set(“b”,“2222”);
map4.set(“c”,“3333”);
var set4 = new Set();
set4.add(“m”);
set4.add(“n”);
set4.add(“L”);
var obj4 = {
name : "jack",
password : "1234"
}
* for…of遍历
// for … of
for(let a of arr4){ //遍历数组
console.info(a);
}
《MySql面试专题》
《MySql性能优化的21个最佳实践》
《MySQL高级知识笔记》
文中展示的资料包括:**《MySql思维导图》《MySql核心笔记》《MySql调优笔记》《MySql面试专题》《MySql性能优化的21个最佳实践》《MySq高级知识笔记》**如下图
关注我,点赞本文给更多有需要的人
g-Jl1n7rtw-1715303353922)]
[外链图片转存中…(img-CuYrlzN1-1715303353922)]
[外链图片转存中…(img-JJOl4hQj-1715303353922)]
[外链图片转存中…(img-dIMtKjcv-1715303353923)]
[外链图片转存中…(img-QRsL5gnF-1715303353923)]
[外链图片转存中…(img-4pgWbCM3-1715303353923)]
[外链图片转存中…(img-ln4jgCJn-1715303353924)]
[外链图片转存中…(img-li2bKKOB-1715303353924)]
[外链图片转存中…(img-gqFqJnGe-1715303353924)]
文中展示的资料包括:**《MySql思维导图》《MySql核心笔记》《MySql调优笔记》《MySql面试专题》《MySql性能优化的21个最佳实践》《MySq高级知识笔记》**如下图
[外链图片转存中…(img-35AnmBk4-1715303353924)]
关注我,点赞本文给更多有需要的人