본문 바로가기

개발/Javascript

(33)
V8 자바 스크립트 엔진 V8 자바 스크립트 엔진 JS에서 DOM으로 추적하고 다시 추적개요Chrome에서 메모리 누수를 디버깅하는 것은 훨씬 쉬워졌습니다. Chrome의 DevTools는 이제 C ++ DOM 객체를 추적하고 스냅 샷을 작성하고 JavaScript를 통해 참조 가능한 모든 DOM 객체를 표시합니다. 이 기능은 V8 가비지 수집기의 새로운 C ++ 추적 메커니즘의 이점 중 하나입니다.배경가비지 콜렉션 시스템에서의 메모리 누수는 다른 오브젝트로부터 의도하지 않은 참조로 인해 사용되지 않은 오브젝트가 해제되지 않은 경우 발생합니다. 웹 페이지의 메모리 누출은 종종 JavaScript 객체와 DOM 요소 간의 상호 작용을 수반합니다.다음 장난감 예 는 프로그래머가 이벤트 리스너의 등록을 잊어 버렸을 때 발생하는 메모리..
이벤트(Events) 이벤트(Events)When attaching data payloads to events (whether DOM events or something more proprietary like Backbone events), pass a hash instead of a raw value. This allows a subsequent contributor to add more data to the event payload without finding and updating every handler for the event. For example, instead of:(DOM이벤트나 Backbone events 와 같은 독자의) 이벤트로 payload의 값을 넘길 경우는 raw값 보다는 해시값을 넘겨 주십시오. ..
억세서(Accessors) 억세서(Accessors)Accessor functions for properties are not required.프로퍼티를 위한 억세서 (Accessor) 함수는 필수는 아닙니다. If you do make accessor functions use getVal() and setVal('hello').억세서 함수가 필요한 경우, getVal() 이나 setVal('hello') 로 해주십시오.// bad dragon.age(); // good dragon.getAge(); // bad dragon.age(25); // good dragon.setAge(25);If the property is a boolean, use isVal() or hasVal().프로퍼티가 boolean 인 경우, isVal()..
명명규칙(Naming Conventions) 명명규칙(Naming Conventions)Avoid single letter names. Be descriptive with your naming.1문자의 이름은 피해 주십시오. 이름으로부터 의도가 읽혀질수 있게 해주십시오.// bad function q() { // ...stuff... } // good function query() { // ..stuff.. }Use camelCase when naming objects, functions, and instances.오브젝트, 함수 그리고 인스턴스에는 camelCase를 사용해 주십시오.// bad const OBJEcttsssss = {}; const this_is_my_object = {}; function c() {} // good const ..
형변환과 강제(Type Casting & Coercion) 형변환과 강제(Type Casting & Coercion) Perform type coercion at the beginning of the statement. 문의 선두에서 형의 강제를 행합니다.Strings:문자열의 경우:// => this.reviewScore = 9; // bad const totalScore = this.reviewScore + ''; // good const totalScore = String(this.reviewScore);Numbers: Use Number for type casting and parseInt always with a radix for parsing strings.수치의 경우: Number 로 형변환하는 경우는 parseInt 를 이용하고, 항상 형변환을 위..
세미콜론(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 ..