FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Update article.md by Kr-Abdou · Pull Request #313 · javascript-tutorial/ar.javascript.info · GitHub

Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .md  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
5 changes: 3 additions & 2 deletions 1-js/05-data-types/05-array-methods/article.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ alert(arr.length); // 3

لهذا السبب علينا استعمال توابِع خاصّة لذلك.

The [arr.splice](mdn:js/Array/splice) method is a swiss army knife for arrays. It can do everything: insert, remove and replace elements.
طريقة [arr.splice](mdn:js/Array/splice) هي سكين سويسري للمصفوفات. يمكنها القيام بكل شيء: إدراج، إزالة، واستبدال العناصر.

هذه صياغته:

```js
arr.splice(start[, deleteCount, elem1, ..., elemN])
```

It modifies `arr` starting from the index `start`: removes `deleteCount` elements and then inserts `elem1, ..., elemN` at their place. Returns the array of removed elements.
تعديل `arr` يبدأ من الفهرس `start`: يزيل `deleteCount` عناصر ثم يقوم بإدراج `elem1, ..., elemN` مكانها. يعيد مصفوفة العناصر المحذوفة.

فهم هذا التابِع بالأمثلة أبسط.

Expand Down Expand Up @@ -411,6 +411,7 @@ alert(arr); // *!*1, 2, 15*/!*
لنتوقف لحظة ونفكّر فيما يحدث تمامًا. أنتّفق بأنّ المصفوفة arr يمكن أن تحتوي أيّ شيء؟ أيّ شيء من الأعداد أو السلاسل النصية أو الكائنات أو غيرها. كلّ ما لدينا هو مجموعة من العناصر. لترتيبها نحتاج دالة ترتيب تعرف طرقة مقارنة عناصر المصفوفة. مبدئيًا، الترتيب يكون بالسلاسل النصية.

The `arr.sort(fn)` method implements a generic sorting algorithm. We don't need to care how it internally works (an optimized [quicksort](https://en.wikipedia.org/wiki/Quicksort) or [Timsort](https://en.wikipedia.org/wiki/Timsort) most of the time). It will walk the array, compare its elements using the provided function and reorder them, all we need is to provide the `fn` which does the comparison.
تقوم طريقة `arr.sort(fn)` بتنفيذ خوارزمية ترتيب عامة. لا نحتاج إلى الاهتمام بكيفية عملها داخليًا (فمعظم الوقت يتم استخدام [ترتيب سريع](https://en.wikipedia.org/wiki/Quicksort) محسّن أو [تيمسورت](https://en.wikipedia.org/wiki/Timsort)). ستمر عبر المصفوفة، تقارن عناصرها باستخدام الدالة المقدمة، وتعيد ترتيبها. كل ما نحتاجه هو توفير الدالة `fn` التي تقوم بالمقارنة.

بالمناسبة، لو أردت معرفة العناصر التي تُوازنها الدالة حاليًا، فلا بأس. لن يقتلك أحد لو عرضتها:

Expand Down

Back | FazBrowse Home | New Git URL