课程链接: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
 

Introduction to ES6上课笔记的更多相关文章

  1. ES6入门笔记

    ES6入门笔记 02 Let&Const.md 增加了块级作用域. 常量 避免了变量提升 03 变量的解构赋值.md var [a, b, c] = [1, 2, 3]; var [[a,d] ...

  2. 面向对象程序设计-C++ Stream & Template & Exception【第十五次上课笔记】

    这是本门<面向对象程序设计>课最后一次上课,刚好上完了这本<Thinking in C++> :) 这节课首先讲了流 Stream 的概念 平时我们主要用的是(1)在屏幕上输入 ...

  3. es6学习笔记-class之一概念

    前段时间复习了面向对象这一部分,其中提到在es6之前,Javasript是没有类的概念的,只从es6之后出现了类的概念和继承.于是乎,花时间学习一下class. 简介 JavaScript 语言中,生 ...

  4. ES6学习笔记<五> Module的操作——import、export、as

    import export 这两个家伙对应的就是es6自己的 module功能. 我们之前写的Javascript一直都没有模块化的体系,无法将一个庞大的js工程拆分成一个个功能相对独立但相互依赖的小 ...

  5. ES6学习笔记<四> default、rest、Multi-line Strings

    default 参数默认值 在实际开发 有时需要给一些参数默认值. 在ES6之前一般都这么处理参数默认值 function add(val_1,val_2){ val_1 = val_1 || 10; ...

  6. ES6学习笔记<三> 生成器函数与yield

    为什么要把这个内容拿出来单独做一篇学习笔记? 生成器函数比较重要,相对不是很容易理解,单独做一篇笔记详细聊一聊生成器函数. 标题为什么是生成器函数与yield? 生成器函数类似其他服务器端语音中的接口 ...

  7. ES6学习笔记<二>arrow functions 箭头函数、template string、destructuring

    接着上一篇的说. arrow functions 箭头函数 => 更便捷的函数声明 document.getElementById("click_1").onclick = ...

  8. ES6学习笔记<一> let const class extends super

    学习参考地址1  学习参考地址2 ECMAScript 6(以下简称ES6)是JavaScript语言的下一代标准.因为当前版本的ES6是在2015年发布的,所以又称ECMAScript 2015:也 ...

  9. ES6读书笔记(三)

    前言 前段时间整理了ES6的读书笔记:<ES6读书笔记(一)>,<ES6读书笔记(二)>,现在为第三篇,本篇内容包括: 一.Promise 二.Iterator和for of循 ...

随机推荐

  1. Linux权限管理(7)

    权限的基本介绍: rwx权限详解: rwx作用到文件: [r]:代表可读,可以读取.查看 [w]:代表可写,可以修改,但不代表可以删除该文件,删除一个文件的前提条件是对该文件所在的目录有写权限才能删除 ...

  2. 使用okHttp登录、Md5密码加密

    1.使用okHttp3登录 2.Md5密码加密 3.完整代码 4.项目案例 使用okHttp3登录: 使用okHttp3之前要在build.gradle引入okHttp3的依赖(顺便引入解析数据的gs ...

  3. Redis学习总结(三)--Redis持久化

    Redis 是将数据存储在内存中的,如果出现断电或系统故障的时候数据就会存在丢失的现象,Redis通过将数据持久化到硬盘中来避免这个问题的出现,我们今天就来学习下 Redis 持久化. Redis 持 ...

  4. 《Effective Java第二版》总结

    第1条:考虑用静态工厂方法代替构造器 通常我们会使用 构造方法 来实例化一个对象,例如: // 对象定义 public class Student{ // 姓名 private String name ...

  5. Leetcode之二分法专题-162. 寻找峰值(Find Peak Element)

    Leetcode之二分法专题-162. 寻找峰值(Find Peak Element) 峰值元素是指其值大于左右相邻值的元素. 给定一个输入数组 nums,其中 nums[i] ≠ nums[i+1] ...

  6. 1.Sentinel源码分析—FlowRuleManager加载规则做了什么?

    最近我很好奇在RPC中限流熔断降级要怎么做,hystrix已经1年多没有更新了,感觉要被遗弃的感觉,那么我就把眼光聚焦到了阿里的Sentinel,顺便学习一下阿里的源代码. 这一章我主要讲的是Flow ...

  7. Python--函数参数类型、用法及代码示例

    在编程语言里,将一个个功能定义成函数,能够进行反复调用,而不是每次都重复相同的代码,这种方式能够大幅度降低代码的复杂度. 函数的好处: 1.代码重用 2.保持一致性 3.可扩展性 1.基础 我们定义函 ...

  8. Date与String之间相互转换

    项目中经常用到,Date类型与String类型的转换,所以写个工具类 直接贴代码: package com.elite.isun.utils; import java.text.ParseExcept ...

  9. 知识图谱推理与实践 (2) -- 基于jena实现规则推理

    本章,介绍 基于jena的规则引擎实现推理,并通过两个例子介绍如何coding实现. 规则引擎概述 jena包含了一个通用的规则推理机,可以在RDFS和OWL推理机使用,也可以单独使用. 推理机支持在 ...

  10. 【selenium】- 自动化测试必备工具FireBug&FirePath

    本文由小编根据慕课网视频亲自整理,转载请注明出处和作者. 1. FireBug FireBug的安装: 如果使用Firefox浏览器的话,推荐使用较低版本,比如27-32.否则会报错. 点击右上角的菜 ...