Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

要不要增加一章,写node4里的es特性? #17

Open
i5ting opened this issue Dec 15, 2015 · 12 comments
Open

要不要增加一章,写node4里的es特性? #17

i5ting opened this issue Dec 15, 2015 · 12 comments

Comments

@i5ting
Copy link
Contributor

i5ting commented Dec 15, 2015

No description provided.

@i5ting
Copy link
Contributor Author

i5ting commented Dec 16, 2015

@i5ting
Copy link
Contributor Author

i5ting commented Dec 20, 2015

Node.js 4.0.0 可以让您享受最尖端的技术,保持项目的先进性。其中对 v8 的升级几乎做到了与 Chromium / Google Chrome 同步,达到了 4.5.x,它提供了很多新的语言功能。ECMA-262 是 JavaScript 语言规范的最新版本,而且好多新特性数都是开箱即用的。这些新特性包括:

  • classes - 各种 ‘类’,再也无需用 CoffeeScript 的语法糖写类了
  • typed arrays - 类型数组
  • generators - 未来的.js 代码中将有无数生成器,不学一点就看不懂 JS 代码了哦
  • collections - 集合、映射、弱集合、弱映射
  • arrow functions - 箭向函数
  • block scoping - 使用 let 、const 作用域,块辖域
  • template strings - 模板字串
  • promises - 用标准化了的方法进行延迟和异步计算
  • symbols - 唯一的、不可修改的数据

@i5ting
Copy link
Contributor Author

i5ting commented Dec 20, 2015

还是应该modern一点,哈哈

@i5ting
Copy link
Contributor Author

i5ting commented Dec 20, 2015

@i5ting
Copy link
Contributor Author

i5ting commented Dec 20, 2015

@zysam
Copy link
Contributor

zysam commented Dec 20, 2015

还要针对场景用好, 不然就写成 es6 入门了。在 koa 下,用最多是 generator ,promise ,另外箭向函数还是慎用,因为 koa 里 上下文 ctx 就是 this,容易走火。希望参考多些例子,总结出最佳实践,避免入坑。

@xxn520
Copy link

xxn520 commented Dec 21, 2015

感觉不用写那么多es6的内容,主要吧generator和promise以及co写详细就可以了,不然感觉有点偏了。

@ghost ghost mentioned this issue Dec 21, 2015
@weifansym
Copy link

es6的基础东西就不要了。。主要讲generator和promise在koa中的使用就好了。。。fashion..modern

@wodog
Copy link

wodog commented Dec 21, 2015

在学习koa的同时也学习了es6,多好呀,作为小白我支持写

@i5ting
Copy link
Contributor Author

i5ting commented Dec 25, 2015

@i5ting
Copy link
Contributor Author

i5ting commented Jan 2, 2016

@zhangguixu
Copy link

zhangguixu commented Nov 1, 2016

第一章的第一节的classes中的setter/getter的例子是错误的

class Polygon{
  constructor(height, width){
      this.height = height;
      this.width = width;
  }
  get name(){
      return this.name;
  }
  set name(somename){
      this.name = somename;
  }
}

这里this.name = somename会引发栈溢出错误,因为无限循环调用set name,希望修正一下

class Polygon{
  constructor(height, width){
      this.height = height;
      this.width = width;
  }
  get name(){
      return this._name;
  }
  set name(name){
      this._name = name;
  }
}

注意到setter和getter的机制,给this.name赋值的时候,就会调用set name @i5ting

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants