Good writing habits js

1: A single judge

bad

if (result) {
   console.log("秋叶");
}
if (!result) {
   console.log("秋叶");
}

good

result && console.log ( "Akiba" ); 
Result || the console.log ( "Akiba");

2: defining a plurality of variables

bad

var a = "aa";
var b = "bb";
var c = "cc";

good

var a = "aa",
   b = "bb",
   c = "cc";

 

Guess you like

Origin www.cnblogs.com/wxydemo/p/12077146.html