|
910 | 910 |
|
911 | 911 |
|
912 | 912 |
|
913 |
| - A. You are not a human code compiler/compressor, so don't try to be one. |
| 913 | + A. Δεν είστε code compiler/compressor, οπότε μην προσπαθείτε να είστε ένας. |
914 | 914 |
|
915 |
| - The following code is an example of egregious naming: |
| 915 | + Ο ακόλουθος κώδικας είναι ένα παράδειγμα από ανήκουστη ονομασία: |
916 | 916 |
|
917 | 917 | ```javascript
|
918 | 918 |
|
919 | 919 | // 6.A.1.1
|
920 |
| - // Example of code with poor names |
| 920 | + // Παράδειγμα κώδικα με φτωχή ονομασία |
921 | 921 |
|
922 | 922 | function q(s) {
|
923 | 923 | return document.querySelectorAll(s);
|
|
926 | 926 | for(i=0;i<els.length;i++){a.push(els[i]);}
|
927 | 927 | ```
|
928 | 928 |
|
929 |
| - Without a doubt, you've written code like this - hopefully that ends today. |
| 929 | + Χωρίς αμφιβολία, έχετε γράψει κώδικα σαν και αυτόν - εύχομαι να τελειώσει σήμερα αυτό. |
930 | 930 |
|
931 |
| - Here's the same piece of logic, but with kinder, more thoughtful naming (and a readable structure): |
| 931 | + Παρακάτω είναι η ίδια λογική, αλλά με πιο καλή ονομασία (ευανάγνωστη δομή): |
932 | 932 |
|
933 | 933 | ```javascript
|
934 | 934 |
|
935 | 935 | // 6.A.2.1
|
936 |
| - // Example of code with improved names |
| 936 | + // Παράδειγμα κώδικα με βελτιωμένη ονομασία |
937 | 937 |
|
938 | 938 | function query( selector ) {
|
939 | 939 | return document.querySelectorAll( selector );
|
|
950 | 950 |
|
951 | 951 | ```
|
952 | 952 |
|
953 |
| - A few additional naming pointers: |
| 953 | + Λίγοι επιπλέον δείκτες ονομασίας: |
954 | 954 |
|
955 | 955 | ```javascript
|
956 | 956 |
|
957 | 957 | // 6.A.3.1
|
958 |
| - // Naming strings |
| 958 | + // Ονομάζοντας strings |
959 | 959 |
|
960 |
| - `dog` is a string |
| 960 | + `dog` είναι ένα string |
961 | 961 |
|
962 | 962 |
|
963 | 963 | // 6.A.3.2
|
964 |
| - // Naming arrays |
| 964 | + // Ονομάζοντας arrays |
965 | 965 |
|
966 |
| - `dogs` is an array of `dog` strings |
| 966 | + `dogs` είναι ένα array από `dog` strings |
967 | 967 |
|
968 | 968 |
|
969 | 969 | // 6.A.3.3
|
970 |
| - // Naming functions, objects, instances, etc |
| 970 | + // Ονομάζοντας functions, objects, instances, κλπ |
971 | 971 |
|
972 | 972 | camelCase; function and var declarations
|
973 | 973 |
|
974 | 974 |
|
975 | 975 | // 6.A.3.4
|
976 |
| - // Naming constructors, prototypes, etc. |
| 976 | + // Ονομάζοντας constructors, prototypes, etc. |
977 | 977 |
|
978 | 978 | PascalCase; constructor function
|
979 | 979 |
|
980 | 980 |
|
981 | 981 | // 6.A.3.5
|
982 |
| - // Naming regular expressions |
| 982 | + // Ονομάζοντας regular expressions |
983 | 983 |
|
984 | 984 | rDesc = //;
|
985 | 985 |
|
986 | 986 |
|
987 | 987 | // 6.A.3.6
|
988 |
| - // From the Google Closure Library Style Guide |
| 988 | + // Από το Google Closure Library Style Guide |
989 | 989 |
|
990 | 990 | functionNamesLikeThis;
|
991 | 991 | variableNamesLikeThis;
|
|
996 | 996 |
|
997 | 997 | ```
|
998 | 998 |
|
999 |
| - B. Faces of `this` |
| 999 | + B. Περιπτώσεις από το `this` |
1000 | 1000 |
|
1001 |
| - Beyond the generally well known use cases of `call` and `apply`, always prefer `.bind( this )` or a functional equivalent, for creating `BoundFunction` definitions for later invocation. Only resort to aliasing when no preferable option is available. |
| 1001 | + Εκτός από τις γενικά γνωστές περιπτώσεις του `call` και του `apply`, πάντα να προτιμάτε το `.bind( this )` ή ένα functional equivalent, για να δημιουργείτε `BoundFunction` definitions για μελλοντική χρήση. Χρησιμοποιείτε μόνο ψευδώνυμα όταν δεν υπάρχει διαθέσιμη επιλογή. |
1002 | 1002 |
|
1003 | 1003 | ```javascript
|
1004 | 1004 |
|
|
1007 | 1007 |
|
1008 | 1008 | this.value = null;
|
1009 | 1009 |
|
1010 |
| - // open an async stream, |
1011 |
| - // this will be called continuously |
| 1010 | + // ανοίξτε ένα async stream, |
| 1011 | + // αυτό θα καλείαι συνεχόμενα |
1012 | 1012 | stream.read( opts.path, function( data ) {
|
1013 | 1013 |
|
1014 |
| - // Update this instance's current value |
1015 |
| - // with the most recent value from the |
| 1014 | + // Ανανεώστε αυτού του instance την τιμή |
| 1015 | + // με την πιο πρόσφατη τιμή από το |
1016 | 1016 | // data stream
|
1017 | 1017 | this.value = data;
|
1018 | 1018 |
|
1019 | 1019 | }.bind(this) );
|
1020 | 1020 |
|
1021 |
| - // Throttle the frequency of events emitted from |
1022 |
| - // this Device instance |
| 1021 | + // Πετάξτε τη συχνότητα των συμβάντων που εκπέμπονται από |
| 1022 | + // αυτήν την εμφάνιση συσκευής |
1023 | 1023 | setInterval(function() {
|
1024 | 1024 |
|
1025 |
| - // Emit a throttled event |
| 1025 | + // Εκπέμπει ένα throttled event |
1026 | 1026 | this.emit("event");
|
1027 | 1027 |
|
1028 | 1028 | }.bind(this), opts.freq || 100 );
|
1029 | 1029 | }
|
1030 | 1030 |
|
1031 |
| - // Just pretend we've inherited EventEmitter ;) |
| 1031 | + // Απλά προσποιηθείτε ότι κάναμε inherit EventEmitter ;) |
1032 | 1032 |
|
1033 | 1033 | ```
|
1034 | 1034 |
|
1035 |
| - When unavailable, functional equivalents to `.bind` exist in many modern JavaScript libraries. |
| 1035 | + Όταν δεν είναι διαθέσιμες, λειτουργικά ισοδύναμα με το `.bind` υπάρχουν σε πολλές σύγχρονες βιβλιοθήκες JavaScript. |
1036 | 1036 |
|
1037 | 1037 |
|
1038 | 1038 | ```javascript
|
1039 | 1039 | // 6.B.2
|
1040 | 1040 |
|
1041 |
| - // eg. lodash/underscore, _.bind() |
| 1041 | + // πχ. lodash/underscore, _.bind() |
1042 | 1042 | function Device( opts ) {
|
1043 | 1043 |
|
1044 | 1044 | this.value = null;
|
|
1056 | 1056 | }, this), opts.freq || 100 );
|
1057 | 1057 | }
|
1058 | 1058 |
|
1059 |
| - // eg. jQuery.proxy |
| 1059 | + // πχ. jQuery.proxy |
1060 | 1060 | function Device( opts ) {
|
1061 | 1061 |
|
1062 | 1062 | this.value = null;
|
|
1074 | 1074 | }, this), opts.freq || 100 );
|
1075 | 1075 | }
|
1076 | 1076 |
|
1077 |
| - // eg. dojo.hitch |
| 1077 | + // πχ. dojo.hitch |
1078 | 1078 | function Device( opts ) {
|
1079 | 1079 |
|
1080 | 1080 | this.value = null;
|
|
1094 | 1094 |
|
1095 | 1095 | ```
|
1096 | 1096 |
|
1097 |
| - As a last resort, create an alias to `this` using `self` as an Identifier. This is extremely bug prone and should be avoided whenever possible. |
| 1097 | + Ως έσχατη λύση, δημιουργήστε ένα ψευδώνυμο στο `this 'χρησιμοποιώντας `self` ως αναγνωριστικό. Αυτό είναι εξαιρετικά επιρρεπές στο σφάλμα και θα πρέπει να αποφεύγεται όποτε είναι δυνατόν. |
1098 | 1098 |
|
1099 | 1099 | ```javascript
|
1100 | 1100 |
|
|
1121 | 1121 | ```
|
1122 | 1122 |
|
1123 | 1123 |
|
1124 |
| - C. Use `thisArg` |
| 1124 | + C. Χρήση `thisArg` |
1125 | 1125 |
|
1126 |
| - Several prototype methods of ES 5.1 built-ins come with a special `thisArg` signature, which should be used whenever possible |
| 1126 | + Αρκετές πρωτότυπες μέθοδοι των ενσωματωμένων ES 5.1 έρχονται με μια ειδική υπογραφή `thisArg`, η οποία θα πρέπει να χρησιμοποιείται όποτε είναι δυνατόν |
1127 | 1127 |
|
1128 | 1128 | ```javascript
|
1129 | 1129 |
|
|
1135 | 1135 |
|
1136 | 1136 | Object.keys( obj ).forEach(function( key ) {
|
1137 | 1137 |
|
1138 |
| - // |this| now refers to `obj` |
| 1138 | + // |this| τώρα αναφέρεται στο `obj` |
1139 | 1139 |
|
1140 | 1140 | console.log( this[ key ] );
|
1141 | 1141 |
|
1142 |
| - }, obj ); // <-- the last arg is `thisArg` |
| 1142 | + }, obj ); // <-- το τελευταίο arg είναι το `thisArg` |
1143 | 1143 |
|
1144 |
| - // Prints... |
| 1144 | + // Εκτυπώνει... |
1145 | 1145 |
|
1146 | 1146 | // "foo"
|
1147 | 1147 | // "bar"
|
1148 | 1148 | // "qux"
|
1149 | 1149 |
|
1150 | 1150 | ```
|
1151 | 1151 |
|
1152 |
| - `thisArg` can be used with `Array.prototype.every`, `Array.prototype.forEach`, `Array.prototype.some`, `Array.prototype.map`, `Array.prototype.filter` |
| 1152 | + `thisArg` μπορεί να χρησιμοποιηθεί με `Array.prototype.every`, `Array.prototype.forEach`, `Array.prototype.some`, `Array.prototype.map`, `Array.prototype.filter` |
1153 | 1153 |
|
1154 | 1154 | 7. <a name="misc">Misc</a>
|
1155 | 1155 |
|
|
0 commit comments