Home > Article > Backend Development > Should single-line comments be placed at the end of the line or above the code?
If it is necessary to add a single-line comment, do developers generally put the single-line comment at the end of the code line, or should it be placed on its own line above the code? Or is it a specific situation and detailed analysis? Is it a personal habit or does it have your reasons. I hope everyone can discuss it so that I can learn more.
End of line
<code>var var1 = 5; // 声明并初始化变量,值为5</code>
Above
<code>// 声明并初始化变量,值为5 var var1 = 5; </code>