개발/Javascript
블록(Blocks)
DANIEL.OH
2018. 3. 11. 14:13
블록(Blocks)
Use braces with all multi-line blocks.
복수행의 블록에는 중괄호 ({}) 를 사용해 주십시오.
// bad if (test) return false; // good if (test) return false; // good if (test) { return false; } // bad function() { return false; } // good function() { return false; }
If you're using multi-line blocks with
if
andelse
, putelse
on the same line as yourif
block's closing brace.복수행 블록의
if
와else
를 이용하는 경우else
는if
블록 끝의 중괄호(})와 같은 행에 위치시켜 주십시오.// bad if (test) { thing1(); thing2(); } else { thing3(); } // good if (test) { thing1(); thing2(); } else { thing3(); }