what and element variable are not defined though code is running

how is compiler know that “element” is the referred to the value of array(prices)

prices.forEach(loop);

function loop(element , what ){
    document.write( what+":"+ element + "<br>");
}

how is compiler know “what” is the index of the array(prices)
and “element” is the value of array(prices)

i was expecting an error since the “element ” and “what ” variable are not defined