We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
在if, else, for, while, do, switch, return, try, catch 后面必须有空格
if
else
for
while
do
switch
return
try
catch
return true;
if(x) { x++; }
if (cond) { foo(); } for (var e in elements) { bar(e); } while (cond) { foo(); }
if (cond){ foo(); } for (var e in elements){ bar(e); } while (cond){ foo(); }
var a = b ? c : d; var a= b ? c : d;
var a = b? c : d; var a = b ?c : d; var a = b ? c: d; var a = b ? c :d;
function () {} function a() {}
function() {} function (){}
var x = 1 , y = 2;
var x = 1; var y = 2;
var x = (1 + 2) * 3;
var x = ( 1 + 2 ) * 3;
var x = { a: { b: 1 }};
var x = {a: 1};
var x = { a: { default: 1 } };
··· var x = {'a': 1}; ···
var x = {a : 1};
?, =, +, -, /, *, ==, ===, !=, !==, >, >=, <, <= 不能被换到下一行。
?
=
+
-
/
*
==
===
!=
!==
>
>=
<
<=
x = y ? 1 : 2; x = y ? 1 : 2;
x = y ? 1 : 2;
++, --, +, -, ~, ! 前缀操作符后面不能有空格。
++
--
~
!
x = !y; y = ++z;
x = ! y; y = ++ z;
++, -- 后缀操作符前不能使用空格。
x = y++; y = z--;
x = y ++; y = z --;
=, +, -, /, *, ==, ===, !=, !== 前后都需要空格。
x !== y;
x!== y; x !==y;
var camelCase = 0; var CamelCase = 1; var _camelCase = 2; var camelCase_ = 3; var UPPER_CASE = 4;
var lower_case = 1; var Mixed_case = 2; var mixed_Case = 3;
var foo = [1, 2, 3]; var bar = {a: "a", b: "b"}
var foo = [1, 2, 3, ]; var bar = {a: "a", b: "b", }
if (x < 0) { x++; } else { x--; }
var a = new B(); var c = new this();
var d = new e();
// A comment /*A comment*/
//A comment
function good() { var obj = { val: true }; return { data: obj }; } if (cond) { foo(); } for (var e in elements) { bar(e); } while (cond) { foo(); }
function bad() { var obj = { val: true }; return { data: obj }; } if (cond) { foo(); } for (var e in elements) { bar(e); } while (cond) { foo(); }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
基本约定
js编码规范
关键字后空格
Valid
Invalid
在代码块前需要空格
Valid
Invalid
在三目表达式中需要有空格
Valid
Invalid
函数表达式前需要空格
Valid
Invalid
单var多声明
Valid
Invalid
在括号的不加空格
Valid
Invalid
Object的包裹应当有空格除非是两个{或}
Valid
Invalid
不允许对象的key有引号括起来
Valid
Invalid
···
var x = {'a': 1};
···
对象的key后面不需要空格
Valid
Invalid
操作符不能被换到下一行
Valid
Invalid
前缀操作符后不能使用空格
Valid
Invalid
后缀操作符前不能使用空格
Valid
Invalid
操作符前后需要空格
Valid
Invalid
驼峰命名,或大写加下划线命名
Valid
Invalid
取出多余的都好,在数组或对象
Valid
Invalid
else不允许换行
Valid
Invalid
类要首字母大写
Valid
Invalid
行备注前有空格
Valid
Invalid
不允许代码块前回车
Valid
Invalid
The text was updated successfully, but these errors were encountered: