airnbn规范示例

来源:互联网 发布:一洋淘宝运营助手破解 编辑:程序博客网 时间:2024/06/11 09:15

https://github.com/airbnb/javascript

点击打开链接

15.7 Avoid unneeded ternary statements. eslint: no-unneeded-ternary

// badconst foo = a ? a : b;const bar = c ? true : false;const baz = c ? false : true;// goodconst foo = a || b;const bar = !!c;const baz = !c;

22.2 Strings:

// => this.reviewScore = 9;// badconst totalScore = this.reviewScore + ''; // invokes this.reviewScore.valueOf()// badconst totalScore = this.reviewScore.toString(); // isn’t guaranteed to return a string// goodconst totalScore = String(this.reviewScore);


  • 22.6 Booleans:

    const age = 0;// badconst hasAge = new Boolean(age);// goodconst hasAge = Boolean(age);// bestconst hasAge = !!age;





原创粉丝点击