freeCodeCamp/guide/arabic/certifications/javascript-algorithms-and-d.../es6/use-the-rest-operator-with-.../index.md

1.4 KiB

title localeTitle
Use the Rest Operator with Function Parameters استخدم المشغل الباقي مع معلمات الدالة

استخدم المشغل الباقي مع معلمات الدالة

تفسير المعلمة الباقية

شبكة مطوري موزيلا

انتشار عامل مقارنة مع المعلمة بقية

تجاوز المكدس

فيديو يشرح الانتشار والراحة

"صورة

[### مثال

هذا الرمز

const product = (function() { "use strict"; return function product(n1, n2, n3) { const args = [n1, n2, n3]; return args.reduce((a, b) => a * b, 1); }; })(); console.log(product(2, 4, 6));//48

يمكن كتابتها على هذا النحو

const product = (function() { "use strict"; return function product(...n) { return n.reduce((a, b) => a * b, 1); }; })(); console.log(product(2, 4, 6));//48 ](http://www.youtube.com/watch?feature=player_embedded&v=iLx4ma8ZqvQ )