课程链接:https://scrimba.com/g/gintrotoes6

这个网站有几个热门的前端技术栈的免费课程,上课体验除了英语渣只能看代码理解听老师讲的一知半解之外,是极佳的学编程的网站了。你跟老师同一个编译器上编译代码,超强体验!!如果跟我一样英语渣,最好结合一下ES6相关书看一下,这样听不懂也看代码也可以知道点在哪里了。

1.Template Literals

let word1 = 'Liu';

let word2 = 'li';

旧:

const fullName = word1 + ''+word2;

fullName = word1 + ''\n + word2;     //Liu

li

新: 

const fullName = `${word1} ${word2}`;   //Liu li

fullName =  `${word1}

${word2}`;     //Liu

li

2.Destructuring Objects

const personalInformation = {

firstName: 'Dylan',
lastName: 'Israel',
city: 'Austin',
state: 'Texas',
zipCode: 73301
};

const {firstName, lastName} = personalInformation;

const {firstName: fn, lastName: ln} = personalInformation;

console.log(`${firstName} ${lastName}`);

console.log(`${fn} ${ln}`);

3.Destructuring Arrays

let [firstName, middleName, lastName] = ['Dylan', 'Coding God', 'Israel'];
lastName = 'Clements';
console.log(lastName)    //Clements

4.Object Literal

function addressMaker(city, state) {
const newAdress = {newCity: city, newState: state};
console.log(newAdress);   // {newCity: "Austin", newState: "Texas"}
}
addressMaker('Austin', 'Texas');
===========ES6====
function addressMaker(city, state) {
const newAdress = {city, state};
console.log(newAdress);   // {city: "Austin", state: "Texas"}
}
addressMaker('Austin', 'Texas');

5.Object Literal(Challenge)

function addressMaker(address) {

const {city, state} = address;
const newAddress = {
city,
state,
country: 'United States'
}; 
}
addressMaker({city: 'Austin', state: 'Texas'});

6.For of Loop

let fullName = "Dylan Coding God Israel";
for (const char of fullName) {
console.log(char);                //D y l a n ....
}

7.For of Loop(Challenge)

let incomes = [62000, 67000, 75000];
for (let income of incomes) {
income += 5000;
}
console.log(incomes);     // [62000, 67000, 75000]
 

8.Spread Operator

let example1 = [1,2,3,4,5,6];
let example2 = [...example1];
example2.push(true);
console.log(example2);   //[1,2,3,4,5,6,true]

9.Rest Operator

function add(...nums){
console.log(nums)    //[4,5,6,7,8]
add(4,5,6,7,8);

10.Arrow Functions

旧:
function add(...nums) {
let total = nums.reduce(function (x, y) {
return x+y;
}); 
console.log(total); //36
}
add(4, 5, 7, 8, 12)
新:
function add(...nums) {
let total = nums.reduce((x, y) => {
return x+y;
});
console.log(total);
}
add(4, 5, 7, 8, 12)
或者是进一步的
function add(...nums) {
let total = nums.reduce((x, y) => x+y);
console.log(total);
}
add(4, 5, 7, 8, 12)

11.Default  Param

function add(numArray = []) {
let total =0;
numArray.forEach((element) => {
total += element;
});
console.log(total);    //0
}
add();

12.includes(除IE)

旧:
let numArray = [1,2,3,4,5];
console.log(numArray.indexOf(0))      //-1
新:
let numArray = [1,2,3,4,5];
console.log(numArray.includes(0))     //false

13.Let&Const

var:
if (false) {
var example=5;
}
console.log(example)   //null
let:

if (false) {
let example =5;
}
console.log(example)   //ReferenceError

const:
const example = [];
example =3;
console.log(example)   //Error
 

const example=[];
example.push(3);
console.log(example)   //[3]

 

const example = {};
example.firstName ='Dylan';
console.log(example)  //{firstName:"Dylan"}

14.padStart()&padEnd()

let example = 'Dylan';
console.log(example.padStart(10, 'a'));  //aaaaaDylan
 

let example = 'Dylan';
console.log(example.padEnd(10, 'a'));  //Dylanaaaaa
 
let example = 'Dylan Irseal';
console.log(example.padEnd(10, 'a'));  //Dylan Irseal

15.Import&Export

---------文件Animal.js-----------
export class Animal {
constructor(type, legs) {
this.type = type;
this.legs = legs;
makeNoise(loudNoise = "loud"){
console.log(loudNoise);
}

}

---------文件index.js----------
import { Animal } from './animal.js';
let cat = new Animal('Cat', 4);
cat.legs = 3;
cat.makeNoise("meow");  //meow
console.log(cat.legs)    //3

16.Classes

-------文件Animal.js----------
export class Animal {
constructor(type, legs) {
this.type = type;
this.legs = legs;
makeNoise(loudNoise = "loud"){
console.log(loudNoise);
}
 
get metaData(){
return `Type:${this.type},Legs:${this.legs}`;
}
 
static return10(){
return 10;
}

}
 
export class Cat extends Animal{
constructor(type,legs,tail){
super(type,legs);
this.tail = tail;

}
makeNoise(loudNoise = "meow"){
console.log(loudNoise);
}

}

------文件index.js--------
import { Animal ,Cat} from './animal.js';
let cat = new Cat('Cat',4,"long");
console.log(Animal.return10());  //10
console.log(cat.metaData);  // Type:Cat,Legs:4
 
cat.makeNoise(); //meow
console.log(cat.metaData) //Type:Cat,Legs:4
console.log(cat.tail)//long

17.Trailing Commas

没听懂

18.Async&Await

const apiUrl = 'https://fcctop100.herokuapp.com/api/fccusers/top/alltime';
function getTop100Campers() {
fetch(apiUrl)
.then((r) => r.json())
.then((json) => {
console.log(json[0])
}).catch((error) => {console.log('faild');});
}
getTop100Campers();  //{username:"sjames1958gm",img:"https//avatars1.githubusercontent.com/u/4639625?v=4",alltime:8826,recent:104,lastUpadate:"2018-04-04T09:10:12.456Z"}
-----await---
const apiUrl = 'https://fcctop100.herokuapp.com/api/fccusers/top/alltime';
function getTop100Campers() {
const response = await fetch(aipUrl);
const json = await response.json();
 
console.log(json[0]);
}
getTop100Campers();  //{username:"sjames1958gm",img:"https//avatars1.githubusercontent.com/u/4639625?v=4",alltime:8826,recent:104,lastUpadate:"2018-04-04T09:10:12.456Z"}

-----async----
没听懂
function resolveAfter3Seconds() {
return new Promise(resolve => {
setTimeout(() => {
resolve('resolved');
}, 3000);
});
}
// resolveAfter3Seconds().then((data) => {
// console.log(data);
// });
async function getAsyncData() {
const result = await resolveAfter3Seconds();
console.log(result);             //resolved
}
getAsyncData();

18.Sets

const exampleSet = new Set([1,1,1,1,2,2,2,2]);
exampleSet.add(5);
exampleSet.add(5).add(17);
console.log(exampleSet.size);   //4

---------delete()----------

console.log(exampleSet.delete(5));  //true
console.log(exampleSet.size);   //3
----------clear()-----
exampleSet.clear();
console.log(exampleSet.size);  //0

转载于:https://www.cnblogs.com/GuliGugaLiz/p/10335067.html

Introduction to ES6上课笔记相关推荐

  1. es6学习笔记-字符串的扩展_v1.0_byKL

    es6学习笔记-字符串的扩展_v1.0 字符的Unicode表示法 JavaScript 允许使用uxxxx的形式表示一个字符,但在 ES6 之前,单个码点仅支持u0000到uFFFF,超出该范围的必 ...

  2. ES6学习笔记(五):轻松了解ES6的内置扩展对象

    前面分享了四篇有关ES6相关的技术,如想了解更多,可以查看以下连接 <ES6学习笔记(一):轻松搞懂面向对象编程.类和对象> <ES6学习笔记(二):教你玩转类的继承和类的对象> ...

  3. ES6学习笔记(三):教你用js面向对象思维来实现 tab栏增删改查功能

    前两篇文章主要介绍了类和对象.类的继承,如果想了解更多理论请查阅<ES6学习笔记(一):轻松搞懂面向对象编程.类和对象>.<ES6学习笔记(二):教你玩转类的继承和类的对象>, ...

  4. ES6入门笔记(一)

    ES6入门笔记(一) 安装babel 由于浏览器对ES6的支持还不是很好,编写ES6代码前我们要安装一个babel工具将ES6代码编译成ES5代码,用如下命令安装babel: npm install ...

  5. ES6学习笔记04:Set与Map

    ES6学习笔记04:Set与Map JS原有两种数据结构:Array与Object,ES6新增两种数据结构:Set与Map 一.Set数据结构 Set类似于数组,但是成员值不允许重复,因此主要用于数据 ...

  6. ES6学习笔记03:变量的解构赋值

    ES6学习笔记03:变量的解构赋值 如果想从复杂数据结构(数组.对象)中获取某一个数据,可能需要大量的遍历操作才能完成.通过解构赋值,这一过程可以得到简化. 1.字符串的解构赋值 其实,Python也 ...

  7. ES6学习笔记02:let 与 const

    ES6学习笔记02:let 与 const 用var声明的变量会造成全局污染,于是就产生了新的声明方式. 1.let 用let声明变量,必须先声明后使用. 在for循环头里用let定义循环变量i,那么 ...

  8. ES6学习笔记01:Symbol数据类型

    ES6学习笔记01:Symbol数据类型 1.Symbol定义 浏览demo01.html: 2.Symbol作对象属性名 Symbol函数可以接收一个字符串作为参数,表示对Symbol实例的描述,输 ...

  9. es6学习笔记-顶层对象_v1.0_byKL

    es6学习笔记-顶层对象_v1.0 (虽然是笔记,但是基本是抄了一次ruan大师的文章了) 顶层对象 顶层对象,在浏览器环境指的是window对象,在Node指的是global对象. ES5之中,顶层 ...

最新文章

  1. 分布式服务框架 Zookeeper — 管理分布式环境中的数据
  2. Layui中Jquery动态设置的select标签加载时而正常时而失效问题排查和解决
  3. android模拟器启动没有拨号功能
  4. 关于推荐系统的一些小结
  5. testng 定时构建_10自动化测试_持续集成篇
  6. 源码分析Dubbo服务提供者启动流程-下篇
  7. 50-000-040-配置-MAC 安装MySQL my.cnf配置文件
  8. python qt库,用于 Python 的高级 GUI 库(Qt 和 PyQt)(1)Unix系统 -电脑资料
  9. 4.8_adapter_结构型模式:适配器模式
  10. 利润从‮而何‬来?​‎
  11. kafka sasl java_kafka 添加SASL鉴权
  12. mysql signal函数_MySQL:简单记录信号处理
  13. 在 CentOS 上安装 Docker 引擎
  14. 隐藏nginx 版本号信息(转)
  15. 区块链 性能测试工具
  16. 22数学建模美赛 22美赛C题
  17. 矩阵理论及其应用课后习题作业:第三章 第四章
  18. c语言写的电脑开关机代码,只需要几行代码制作电脑开关机控制软件
  19. ALT+数字键显示的标点符号大全
  20. 六年Android生涯总结+展望:君子坐而论道,少年起而行之

热门文章

  1. linux命令行总结
  2. ST_LINK/V2 SWIM和SWD、JTAG下载口说明
  3. c如何返回数组给java
  4. 前端学习(3192):react第一个案例
  5. 前端学习(2978):上午回顾
  6. [css] 移动端的布局用过媒体查询吗?写出例子看看
  7. 工作272:上传部分代码优化之两种上传视频的方式
  8. 前端学习(2561):页面更新
  9. 前端学习(2372):uni-ui库
  10. 前端学习(2225):react之类定义组件