شرح صفوف ومحتوى الفقرة
عندما تطلب الدالة معاملات إضافية إلى جانب سياق this، نمررها إلى .call() مفردةً واحداً تلو الآخر مفصولةً بفواصل بعد كائن السياق مباشرةً بالصيغة fn.call(contextObj, arg1, arg2).
JavaScript
function buildLine(currency, discount) {
const finalPrice = this.price - discount;
return this.item + ': ' + finalPrice + ' ' + currency;
}
const product = { item: 'Keyboard', price: 250 };
document.getElementById('args-out').textContent = buildLine.call(product, 'SAR', 30);