0128 JavaScript code specification: naming identifier, the operator specifications, single-line comments specification, other specifications

2.1 identifier naming convention

  • Variable and function names must be meaningful
  • Name of the variable general noun
  • Verb general name of the function

2.2 Operators Specification

// 操作符的左右两侧各保留一个空格
for (var i = 1; i <= 5; i++) {
   if (i == 3) {
       break; // 直接退出整个 for 循环,跳到整个for循环下面的语句
   }
   console.log('我正在吃第' + i + '个包子呢');
}

2.3 Single-line comments Specification

for (var i = 1; i <= 5; i++) {
   if (i == 3) {
       break; // 单行注释前面注意有个空格
   }
   console.log('我正在吃第' + i + '个包子呢');
}

2.4 Other specifications

关键词、操作符之间后加空格

Guess you like

Origin www.cnblogs.com/jianjie/p/12145270.html