Bản đồ lồng nhau javascript
This document serves as the complete definition of Google’s coding standards for source code in the JavaScript programming language. A JavaScript source file is described as being in Google Style if and only if it adheres to the rules herein Show
Like other programming style guides, the issues covered span not only aesthetic issues of formatting, but other types of conventions or coding standards as well. However, this document focuses primarily on the hard-and-fast rules that we follow universally, and avoids giving advice that isn't clearly enforceable (whether by human or tool) 1. 1 Terminology notesIn this document, unless otherwise clarified
Other terminology notes will appear occasionally throughout the document 1. 2 Guide notesExample code in this document is non-normative. That is, while the examples are in Google Style, they may not illustrate the only stylish way to represent the code. Optional formatting choices made in examples must not be enforced as rules 2 Source file basics2. 1 File nameFile names must be all lowercase and may include underscores ( 49) or dashes ( 50), but no additional punctuation. Follow the convention that your project uses. Filenames’ extension must be 512. 2 File encoding. UTF-8Source files are encoded in UTF-8 2. 3 Special characters2. 3. 1 Whitespace charactersAside from the line terminator sequence, the ASCII horizontal space character (0x20) is the only whitespace character that appears anywhere in a source file. This implies that
2. 3. 2 Special escape sequencesFor any character that has a special escape sequence ( 52, 53, 54, 55, 56, 57, 58, 59, 60), that sequence is used rather than the corresponding numeric escape (e. g 61, 62, or 63). Legacy octal escapes are never used2. 3. 3 Non-ASCII charactersFor the remaining non-ASCII characters, either the actual Unicode character (e. g. 64) or the equivalent hex or Unicode escape (e. g. 65) is used, depending only on which makes the code easier to read and understandTip. In the Unicode escape case, and occasionally even when actual Unicode characters are used, an explanatory comment can be very helpful 8
Mẹo. Đừng bao giờ làm cho mã của bạn khó đọc hơn chỉ vì sợ rằng một số chương trình có thể không xử lý đúng các ký tự không phải ASCII. If that happens, those programs are broken and they must be fixed 3 Source file structureAll new source files should either be a 66 file (a file containing a 66 call) or an ECMAScript (ES) module (uses 68 and 69 statements). Files consist of the following, in order
Chính xác một dòng trống phân tách từng phần hiện có, ngoại trừ phần triển khai của tệp, có thể có 1 hoặc 2 dòng trống trước 3. 1 Giấy phép hoặc thông tin bản quyền, nếu cóNếu thông tin giấy phép hoặc bản quyền thuộc về một tệp, thì nó thuộc về đây 3. 2 /* Poor: the reader has no idea what character this is. */ const units = '\u03bcs'; 70 JSDoc, nếu cóNhìn thấy ?? 3. 3 /* Poor: the reader has no idea what character this is. */ const units = '\u03bcs'; 66 statementTất cả các tệp 66 phải khai báo chính xác một tên 66 trên một dòng. các dòng chứa khai báo 66 không được ngắt dòng và do đó là ngoại lệ đối với giới hạn 80 cộtToàn bộ đối số với google. mô-đun là những gì xác định một không gian tên. Đó là tên gói (một mã định danh phản ánh đoạn cấu trúc thư mục chứa mã) cộng với, tùy chọn, lớp/enum/giao diện chính mà nó xác định được nối vào cuối Thí dụ 53. 3. 1 thứ bậcKhông gian tên mô-đun không bao giờ được đặt tên là con trực tiếp của không gian tên mô-đun khác không được phép 6Hệ thống phân cấp thư mục phản ánh hệ thống phân cấp không gian tên, sao cho các thư mục con được lồng sâu hơn là các thư mục con của các thư mục mẹ cấp cao hơn. Lưu ý rằng điều này ngụ ý rằng chủ sở hữu của các nhóm không gian tên "cha mẹ" nhất thiết phải biết tất cả các không gian tên con, vì chúng tồn tại trong cùng một thư mục 3. 3. 2 /* Poor: the reader has no idea what character this is. */
const units = '\u03bcs';
|