ouvens.github.io icon indicating copy to clipboard operation
ouvens.github.io copied to clipboard

有问题可以这里交流哦

Open ouvens opened this issue 9 years ago • 9 comments

有问题可以这里交流哦

ouvens avatar Aug 20 '16 01:08 ouvens

Win10 64 Pro Node.js 6.9.1

1.块级作用域 第1次 ES5: 21ms,ES6: 12ms 之後 ES5: 10ms,ES6: 11ms

2.Class ES5: 2ms,ES6: 3ms

3.Map ES5: 7ms,ES6: 75ms

4.字符串模板 ES5: 5ms,ES6: 14ms

Cow258 avatar Oct 23 '16 18:10 Cow258

嗯,其实具体来看,ES6+高级特性所需要的时间确实是要长些的。

ouvens avatar Oct 31 '16 08:10 ouvens

it is awsome,helpful

lazyTai avatar Nov 03 '16 15:11 lazyTai

代码字体能改下吗?看得太难受了,大块的代码都跳过去了没看,挤在一起还是花体字根本看不清

Jack-Sparrow avatar Jan 17 '17 12:01 Jack-Sparrow

恩,谢谢建议。github多次更换markdown解析引擎,导致旧的文章中代码显示有点问题,抽空尽量修复下

ouvens avatar Jan 22 '17 08:01 ouvens

bugs

// <del>good</del> BAD
var errorMessage = 'This is a super long error that ' +
  'was thrown because of Batman.' +
  'When you stop to think about ' +
  'how Batman had anything to do ' +
  'with this, you would get nowhere ' +
  'fast.';
  

构建多行字符串时, 使用模板字符串!

// good
let errorMessage = `This is a super long error that 
   was thrown because of Batman. 
   When you stop to think about 
   how Batman had anything to do 
   with this, you would get nowhere 
   fast.
`;
  

xgqfrms-GitHub avatar Feb 20 '17 18:02 xgqfrms-GitHub

https://github.com/airbnb/javascript/blob/master/README.md#strings--line-length

6.2 Strings that cause the line to go over 100 characters should not be written across multiple lines using string concatenation.

Why? Broken strings are painful to work with and make code less searchable.

// good
const errorMessage = ' This is a super long error that was thrown because of Batman. When you stop to think about how Batman had anything to do with this, you would get nowhere fast. ';

xgqfrms-GitHub avatar Feb 20 '17 18:02 xgqfrms-GitHub

既然是中文社区我就用中文留言吧。

不知道有没有真的去实践过这些代码,我发现作者使用的mobx版本是2.5.1。但是我发现部分代码在这个版本下根本跑不通,甚至在其他版本里也是不行的。

比如person那个例子:

var person = mobx.observable({
    firstName: 'Matt',
    lastName: 'Ruby',
    age: 37,
    fullName: function () {
    this.firstName + ' ' + this.lastName;
    }
});
mobx.autorun(function () {
    console.log('Full name: ' + person.fullName);
});

person.age = 38; // 不打印内容
person.lastName = 'RUBY!'; // 打印内容
person.firstName = 'Matthew!'; // 打印内容

fullName方法在定义的时候就存在问题,首先要用es5 getter方式来定义,并且要确定返回值。所以正确的版本如下:

var person = mobx.observable({
    firstName: 'Matt',
    lastName: 'Ruby',
    age: 37,
    get fullName () {
      return this.firstName + ' ' + this.lastName;
    }
});
mobx.autorun(function () {
    console.log('Full name: ' + person.fullName);
});

这样错误的例子在本文里数不胜数,这里并没有责备译者的意思,因为原文本身就存在着问题。

(上述本人所言如若有误,请各位指出。

dcalsky avatar May 17 '17 05:05 dcalsky

不错不错

jkkhello avatar Oct 11 '17 03:10 jkkhello