코멘트(Comments)
Use
/** ... */for multi-line comments. Include a description, specify types and values for all parameters and return values.복수행의 코멘트는
/** ... */을 사용해 주십시오. 그 안에는 설명과 모든 파라메터, 반환값에 대해 형이나 값을 기술해 주십시오.// bad // make() returns a new element // based on the passed in tag name // // @param {String} tag // @return {Element} element function make(tag) { // ...stuff... return element; } // good /** * make() returns a new element * based on the passed in tag name * * @param {String} tag * @return {Element} element */ function make(tag) { // ...stuff... return element; }
Use
//for single line comments. Place single line comments on a newline above the subject of the comment. Put an empty line before the comment unless it's on the first line of a block.단일행 코멘트에는
//을 사용해 주십시오. 코멘트를 추가하고 싶은 코드의 상부에 배치해 주십시오. 또한, 코멘트의 앞에 빈행을 넣어 주십시오.// bad const active = true; // is current tab // good // is current tab const active = true; // bad function getType() { console.log('fetching type...'); // set the default type to 'no type' const type = this._type || 'no type'; return type; } // good function getType() { console.log('fetching type...'); // set the default type to 'no type' const type = this._type || 'no type'; return type; } // also good function getType() { // set the default type to 'no type' const type = this._type || 'no type'; return type; }
Prefixing your comments with
FIXMEorTODOhelps other developers quickly understand if you're pointing out a problem that needs to be revisited, or if you're suggesting a solution to the problem that needs to be implemented. These are different than regular comments because they are actionable. The actions areFIXME -- need to figure this outorTODO -- need to implement.문제를 지적하고 재고를 촉구하는 경우나 문제의 해결책을 제안하는 경우 등, 코멘트의 앞에
FIXME나TODO를 붙이는 것으로 다른 개발자의 빠른 이해를 도울수 있습니다. 이런것들은 어떤 액션을 따른다는 의미로 통상의 코멘트와는 다릅니다. 액션이라는 것은FIXME -- 해결이 필요또는TODO -- 구현이 필요를 뜻합니다.문제에 대한 주석으로써
// FIXME:를 사용해 주십시오.class Calculator extends Abacus { constructor() { super(); // FIXME: shouldn't use a global here // FIXME: 글로벌변수를 사용해서는 안됨. total = 0; } }
Use
// TODO:to annotate solutions to problems.문제의 해결책에 대한 주석으로
// TODO:를 사용해 주십시오.class Calculator extends Abacus { constructor() { super(); // TODO: total should be configurable by an options param // TODO: total 은 옵션 파라메터로 설정해야함. this.total = 0; } }
'개발 > Javascript' 카테고리의 다른 글
| 콤마(Commas) (0) | 2018.03.11 |
|---|---|
| 공백(Whitespace) (0) | 2018.03.11 |
| 블록(Blocks) (0) | 2018.03.11 |
| 프로퍼티(Properties) (0) | 2018.03.11 |
| Arrow함수(Arrow Functions) (0) | 2018.03.11 |