tarena
3 years agoNew Contributor III
Arrow Function Parameters
I’m trying to understand the documentation for the Array function toObject.
It uses [‘zero’, ‘one’, ‘two’].toObject((x, index) => index, x => x.contains(‘two’)) as an example, which returns {“0”: false, “1”: false, “2”: true}.
What does the (x, index) portion of the expression mean? If I reverse the order to {index, x}, use {index}, or use index then the output always returns {zero:false, one:false, two:true}. What is (x, index) and why is it special here?