يُعتبر كائن الوسيطات كائنًا **شبيهًا بالصفيف**_(في أن بنية الكائن تشبه كائن الصفيف ، ومع ذلك لا ينبغي اعتبارها صفيفًا كما تحتوي على جميع وظائف كائن)_ التي تخزن جميع الوسيطات التي تم تمريرها إلى وظيفة وهي ملكية خاصة لتلك الوظيفة. لو كنت لتمر 3 الحجج إلى وظيفة، ويقول `storeNames()` ، سيتم تخزين هذه الحجج 3 داخل الكائن يسمى **الحجج** وسيبدو هذا عندما نعبر الحجج `storeNames("Mulder", "Scully", "Alex Krycek")` إلى `storeNames("Mulder", "Scully", "Alex Krycek")` :
* أولاً ، نعلن عن وظيفة ونجعلها ترجع كائن الوسائط.
* Then, when we execute that function with **n arguments**, 3 in this case, it will return the object to us and it will **look like** an array. We can convert it to an array, but more on that later...
جافا سكريبت // إذا قمنا بتنفيذ السطر التالي في وحدة التحكم: storeNames ("Mulder"، "Scully"، "Alex Kryceck")؛ // سيكون الناتج {'0': 'Mulder' ، '1': 'Scully' ، '2': 'Alex Kryceck'}
``If you want to know more about this, such as converting it to an array or the optimization problem that comes with using the _slice(_) method and how to solve it, click on **read more** (Gitter Chat Only).
## Treat it as an array
You can invoke arguments by using `arguments[n]` (where _n_ is the index of the argument in the array-like object) but if you want to use it as an array for iteration purposes or applying array methods to it, you need to _convert it to an array_ by declaring a variable and using the Array.prototype.slice.call method (because _arguments_ is not an array):
``
جافا سكريبت var args = Array.prototype.slice.call (الحجج) ؛
Since **slice()** has two (the parameter **end** is optional) parameters, you can grab a certain portion of the arguments by specifying (using the _slice.call()_ method renders these two parameters optional, not just _end_) the beginning and the ending of your portion; check out the following code:
// يجب أن يكون الناتج: // // \[100 ، 75\] <-لماذا؟لأنهبدأمنالفهرس1وتوقفعندالفهرس3//لذلك،لميؤخذفيالاعتبارالمؤشر3(40).////إذاأزلناالمعلمة"3"،لننتركهاسوى(الحجج،1)//كلحجةمنالفهرس1: \[100،75،40،89،95\].
There is a little problem, it's not recommended to use slice in the arguments object (optimization reasons)...
> **Important**: You should not slice on arguments because it prevents optimizations in JavaScript engines (V8 for example). Instead, try constructing a new array by iterating through the arguments object.
جافا سكريبت var args = \[\]؛ // صفيف فارغ ، في البداية. لـ (var i = 0؛ i <arguments.length؛i++){args.push(الحجج \[أنا\])}//Now'args'هيمصفوفةتحملوسائطك. \`\` \`