본문 바로가기

분류 전체보기

(135)
세미콜론(Semicolons) 세미콜론(Semicolons)// bad (function() { const name = 'Skywalker' return name })() // good (() => { const name = 'Skywalker'; return name; })(); // good (guards against the function becoming an argument when two files with IIFEs are concatenated) // good (즉시함수가 연결된 2개의 파일일때 인수가 되는 부분을 보호합니다. ;(() => { const name = 'Skywalker'; return name; })();
콤마(Commas) 콤마(Commas)Leading commas: Nope.선두의 콤마 하지마요// bad const story = [ once , upon , aTime ]; // good const story = [ once, upon, aTime, ]; // bad const hero = { firstName: 'Ada' , lastName: 'Lovelace' , birthYear: 1815 , superPower: 'computers' }; // good const hero = { firstName: 'Ada', lastName: 'Lovelace', birthYear: 1815, superPower: 'computers', };Additional trailing comma: Yup.끝의 콤마 좋아요Why? Thi..
공백(Whitespace) 공백(Whitespace)Use soft tabs set to 2 spaces.탭에는 스페이스 2개를 설정해 주십시오.// bad function() { ∙∙∙∙const name; } // bad function() { ∙const name; } // good function() { ∙∙const name; }Place 1 space before the leading brace.주요 중괄호 ({}) 앞에는 스페이스를 1개 넣어 주십시오.// bad function test(){ console.log('test'); } // good function test() { console.log('test'); } // bad dog.set('attr',{ age: '1 year', breed: 'Bernese ..
코멘트(Comments) 코멘트(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; } /..
블록(Blocks) 블록(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 and else, put else on the same line as your if block's closing brace.복수행 블록의 if 와 else 를 이용하는 경우 else 는 if ..
프로퍼티(Properties) 프로퍼티(Properties)Use dot notation when accessing properties.프로퍼티에 억세스하는 경우는 점 . 을 사용해 주십시오.const luke = { jedi: true, age: 28, }; // bad const isJedi = luke['jedi']; // good const isJedi = luke.jedi;Use subscript notation [] when accessing properties with a variable.변수를 사용해 프로퍼티에 억세스하는 경우는 대괄호 [] 를 사용해 주십시오.const luke = { jedi: true, age: 28, }; function getProp(prop) { return luke[prop]; } const..
Arrow함수(Arrow Functions) Arrow함수(Arrow Functions)When you must use function expressions (as when passing an anonymous function), use arrow function notation.(무명함수를 전달하는 듯한)함수식을 이용하는 경우 arrow함수 표기를 이용해 주십시오.Why? It creates a version of the function that executes in the context of this, which is usually what you want, and is a more concise syntax.왜? arrow함수는 그 context의 this 에서 실행하는 버전의 함수를 작성합니다. 이것은 통상 기대대로의 동작을 하고, 보다 간..
조건식과 등가식(Comparison Operators & Equality) 조건식과 등가식(Comparison Operators & Equality)Use === and !== over == and !=.== 이나 != 보다 === 와 !== 을 사용해 주십시오.Conditional statements such as the if statement evaluate their expression using coercion with the ToBooleanabstract method and always follow these simple rules:Objects evaluate to trueUndefined evaluates to falseNull evaluates to falseBooleans evaluate to the value of the booleanNumbers evalu..