You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 1-js/04-object-basics/01-object/article.md
+39-39Lines changed: 39 additions & 39 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -418,9 +418,9 @@ for (let key in user) {
418
418
419
419
هل الكائنات مرتبة? بمعنى آخر, إن تنقلنا في حلقة خلال كائن, هل نحصل على جميع الخاصيات بنفس الترتيب الذي أُضيفت به؟ وهل يمكننا الاعتماد على هذا؟
420
420
421
-
The short answer is: "ordered in a special fashion": integer properties are sorted, others appear in creation order. The details follow.
421
+
الإجابة باختصار هي: "مرتب بطريقة خاصة": الخاصيات الرقمية يُعاد ترتيبها، تظهر باقي الخاصيات بترتيب الإنشاء ذاته كما في التفاصيل التالية.
422
422
423
-
As an example, let's consider an object with the phone codes:
423
+
مثال, لنر كائناً خصائصه رموز الهاتف:
424
424
425
425
```js run
426
426
let codes = {
@@ -438,29 +438,29 @@ for (let code in codes) {
438
438
*/!*
439
439
```
440
440
441
-
The object may be used to suggest a list of options to the user. If we're making a site mainly for German audience then we probably want`49`to be the first.
441
+
قد يستخد الكائن لاقتراح قائمة من الخيارات للمستخدم. إن كنا نقوم بعمل الموقع بشكل رئيسي للزوار الألمان فإننا نريد أن يظهر`49`في أول القائمة.
442
442
443
-
But if we run the code, we see a totally different picture:
443
+
لكن إذا قمنا بتشغيل الكود, فإننا نرى صورة مختلفة تماماً:
444
444
445
-
- USA (1) goes first
446
-
- then Switzerland (41) and so on.
445
+
- USA (1) تظهر أولاً
446
+
- ثم Switzerland (41) وهكذا.
447
447
448
-
The phone codes go in the ascending sorted order, because they are integers. So we see`1, 41, 44, 49`.
448
+
تستخدم رموز الهاتف بشكل تصاعدي , لأنها أرقام. لذلك`1, 41, 44, 49`.
alert( String(Math.trunc(Number("+49"))) ); // "49" مختلفة عن "49+" => إذًا ليست خاصية عددية
459
+
alert( String(Math.trunc(Number("1.2"))) ); // "1" مختلفة عن "1.2" => إذًا ليست خاصية عددية
460
460
```
461
461
````
462
462
463
-
...On the other hand, if the keys are non-integer, then they are listed in the creation order, for instance:
463
+
...في المقابل، إن كانت المفاتيح غير عددية، فتُعرَض بالترتيب الذي أُنشِئت به,مثلا:
464
464
465
465
```js run
466
466
let user = {
@@ -470,16 +470,16 @@ let user = {
470
470
user.age=25; // add one more
471
471
472
472
*!*
473
-
//non-integer properties are listed in the creation order
473
+
//تُعرض الخاصيات الغير رقمية بترتيب الإنشاء
474
474
*/!*
475
475
for (let prop in user) {
476
476
alert( prop ); // name, surname, age
477
477
}
478
478
```
479
479
480
-
So, to fix the issue with the phone codes, we can "cheat" by making the codes non-integer. Adding a plus `"+"`sign before each code is enough.
480
+
لذا, لإصلاح هذه المشكلة مع رموز الهاتف, يمكننا "التحايل" بجعلها غير عددية. وضع علامة `"+"`قبل كل رمز يعتبر كافياً.
481
481
482
-
Like this:
482
+
كما يلي:
483
483
484
484
```js run
485
485
let codes = {
@@ -495,34 +495,34 @@ for (let code in codes) {
495
495
}
496
496
```
497
497
498
-
Now it works as intended.
498
+
والآن تعمل وفق المطلوب.
499
499
500
-
## Summary
500
+
## الملخص
501
501
502
-
Objects are associative arrays with several special features.
502
+
الكائنات عبارة عن مصفوفات ترابطية بميزات خاصة عديدة.
503
503
504
-
They store properties (key-value pairs), where:
505
-
- Property keys must be strings or symbols (usually strings).
506
-
- Values can be of any type.
504
+
تحفظ الخصائص ب (key-value pairs), حيث:
505
+
- مفاتيح الخواص يجب أن تكون نصاً أو رمزاً (عادة ما تكون نصاً).
506
+
- القيم يمكن أن تكون من أي نوع.
507
507
508
-
To access a property, we can use:
509
-
- The dot notation: `obj.property`.
510
-
- Square brackets notation`obj["property"]`. Square brackets allow to take the key from a variable, like`obj[varWithKey]`.
508
+
للوصول إلى خاصية, يمكننا استخدام:
509
+
- رمز النقطة: `obj.property`.
510
+
- رمز الأقواس المربعة`obj["property"]`. تسمح الأقواس المربعة بأخذ المفتاح من متغير, مثل`obj[varWithKey]`.
511
511
512
-
Additional operators:
513
-
- To delete a property: `deleteobj.prop`.
514
-
- To check if a property with the given key exists: `"key"in obj`.
515
-
- To iterate over an object: `for (let key in obj)` loop.
512
+
معاملات إضافية Additional operators:
513
+
- لحذف خاصية: `deleteobj.prop`.
514
+
- للتأكد من وجود خاصية تحمل المفتاح المعطى: `"key"in obj`.
515
+
- للتنقل خلال كائن: `for (let key in obj)` loop.
516
516
517
-
What we've studied in this chapter is called a "plain object", or just`Object`.
517
+
ما درسناه في هذا الفصل يسمى "plain object", أو`Object`.
518
518
519
-
There are many other kinds of objects in JavaScript:
519
+
هنالك أنواع عديدة من الكائنات في الجافا اسكريبت:
520
520
521
-
- `Array`to store ordered data collections,
522
-
- `Date`to store the information about the date and time,
523
-
- `Error`to store the information about an error.
524
-
- ...And so on.
521
+
- `Array`مصفوفة لتخزين مجموعة البيانات المرتبة,
522
+
- `Date`تاريخ لتخزين معلومات عن الوقت والتاريخ,
523
+
- `Error`خطأ لتخزين معلومات عن خطأ ما.
524
+
- ...وما إلى ذلك.
525
525
526
-
They have their special features that we'll study later. Sometimes people say something like "Array type" or "Date type", but formally they are not types of their own, but belong to a single "object" data type. And they extend it in various ways.
526
+
لدى هذه الأنواع ميزاتها الخاصة التي سيتم دراستها لاحقًا. يقول بعض الأشخاص أحيانًا شيئًا مثل "نوع مصفوفة" أو "نوع تاريخ", لكن هذه الأنواع ليست أنواعًا مستقلة بحد ذاته, لكنها تنتمي "object" نوع البانات"كائن". وتتفرع عنه بأشكال مختلفة.
527
527
528
-
Objects in JavaScript are very powerful. Here we've just scratched the surface of a topic that is really huge. We'll be closely working with objects and learning more about them in further parts of the tutorial.
528
+
تعد الكائنات في جافا اسكريبت قوية جدا. هنا قمنا بعرض سطح موضوع ضخم حقًا. سنتعامل مع الكائنات لاحقًا بصورة أقرب وسَنتعلم أكثر عنها في فصول أخرى.
0 commit comments