Where destructuring in ES6 allows you to easily get properties out of an object, this shorthand property syntax allows you to easily push properties in. let firstName = "Answer"; let lastName = "Question"; let person = {firstName, last…
es是js的规范,而js是具体实现 将es6转化为es5代码工具:运用的多的是babel 在线转换地址:babel,traceur(属于谷歌) 1.let申明变量:let其实可以完全取代var,并且没有var这么多副作用 { var a = 10; let b = 10;//let申明的变量是块级作用域 } console.log(a) // console.log(b)//b is not defined let很适合的一种场景是:for for (let i = 0; i < 3; i+…
1.for of 值遍历 for in 循环用于遍历数组,类数组或对象,ES6中新引入的for of循环功能相似,不同的是每次循环它提供的不是序号而是值. var someArray = [ "a", "b", "c" ]; for (v of someArray) { console.log(v);//输出 a,b,c } 2.iterator, generator基本概念 2.1 iterator:它是这么一个对象,拥有一个next方法,这个…
参考链接: http://www.jianshu.com/p/ebfeb687eb70 http://www.cnblogs.com/Wayou/p/es6_new_features.html 1.let, const 这两个的用途与var类似,都是用来声明变量的,但在实际运用中他俩都有各自的特殊用途. 1.1第一种场景就是你现在看到的内层变量覆盖外层变量 var name = 'zach' while (true) { var name = 'obama' console.log(name)…